programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

# Help with Simple Home Work

Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
im learning java, but i like to learn it without someone breathing over my neck!

im still new but my teacher wont understand.

Question 2: Write short Java statements to do the following (4 pt)
2.1 Consider the BankAccount class, add a new method IncreaseBalance that raises the current balance by a given percentage.
For example, a Bank Account with balance 100 \$ will increase to 150 \$ if the percentage is 0.5 (2pt)
2.2 Write only one statement to compute the length of a string str. (2pt)
Question 3: Write complete Java programs and provide a screen snapshot showing your program in execution to receive full credit.
(7 pts)
3.1 Body Mass Index (BMI) is measure for body fitness that takes weight and height into account. Usually, a BMI above 25 is considered high and likely to indicate overweight. BMI is calculated from the equation:
10000 × (𝑤) h2
Where w is weight in kilograms and h is height in centimeters.
Write a program that asks the user about his/her width and height and output
the corresponding BMI. (3 pts)
3.2 In the 2- dimensional plane, a point is described by its two coordinates x and y. It supports these operations :
- A constructor allowing initialization of both coordinates - Accessors and mutators to its coordinates
- Translation of a point
a. Write a class, called MyPoint that corresponds to an abstraction of points in the dimensional plane. (2 pts)
b. Provide a tester class that creates one point, then translate and display the new coordinates. (2 pts)

Screen-Shot-2015-10-16-at-6.03.09-PM.png

Marshal
Posts: 76885
366
• Number of slices to send:
Optional 'thank-you' note:
Welcome to the Ranch

We do not provide answers but will help if you show us what you have achieved so far.

Campbell Ritchie
Marshal
Posts: 76885
366
• Number of slices to send:
Optional 'thank-you' note:

max ace wrote:. . . i like to learn it without someone breathing over my neck!

im still new but my teacher wont understand.
. . .

Careful what you say. That sort of thing can be misunderstood as rudeness about your teacher.

lowercase baba
Posts: 13082
67
• Number of slices to send:
Optional 'thank-you' note:
Exactly what kind of help do you need? At this point, we don't know if you need help installing the JDK, compiling a valid .java file, or any of about a billion other possibilities.

What have you got so far? Can you compile and run a simple "helloWorld.java" program? Please be specific.

Campbell Ritchie
Marshal
Posts: 76885
366
• Number of slices to send:
Optional 'thank-you' note:
The formula for BMI is
10000 × w ÷ h²

maxwell hunter
Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
sorry im new to this
but this is what i got so far

2.1

3.1

3.2

Bartender
Posts: 732
10
• Number of slices to send:
Optional 'thank-you' note:
Your increase function for question 2.1 is incorrect. if the original balance was 100 and percentage is 0.5, your result will be 50, not 150.

Campbell Ritchie
Marshal
Posts: 76885
366
• Number of slices to send:
Optional 'thank-you' note:
I have added code tags to your posts. Always use the tags: doesn't it look better

I think your BMI code will work. But it can be improved. Find out about the use of printf and the % tags to print the result. Also find out why the round() call is unnecessary. Also find out about moving code out of the main method.
For the other two you need some testing code.That is an example of what will show whether your Point class works. It will need a toString method before you get decent output. Please improve the formatting in all your code; we have some suggestions here. That will make it look better. I like the way you have written nice short simple methods in the point class, but I can see a problem in the translate method. Why have you got that import; you are not using anything from that package?

I think you will have to think again about the bank class, I am afraid. Again you will need testing code similar to that for point.

Bartender
Posts: 689
17
• Number of slices to send:
Optional 'thank-you' note:
Let's keep this simple and deal with one thing at a time so we don't all get confused.

Question 2.1 asks you to add a method to the BankAccount that will increase the amount of money on the account by a specified percentage of the current balance.

It gives the example that given a BankAccount with \$100 in it, if the percentage is 0.5 the result should be \$150.

Does your current solution give that result?

Edit: I assume the questioner is confusing fractions and percentages, so 0.5 means 50%, not 0.5%.

Mike. J. Thompson
Bartender
Posts: 689
17
• Number of slices to send:
Optional 'thank-you' note:
Also check the spec for question 2.1. There is an important part of the spec (other than the calculation) that you need to look at.

maxwell hunter
Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
thank you for the code tags Sheriff

and thank you all for coming up and helping me with my problem.

as long as the BMI code is ok, i think i should focus on the Bank Account.

thanks again...

Campbell Ritchie
Marshal
Posts: 76885
366
• Number of slices to send:
Optional 'thank-you' note:
You're welcome

Sheriff
Posts: 8544
615
• Number of slices to send:
Optional 'thank-you' note:
Hi, when you write BankAccount class, you also could try to think of having overloaded constructor and what kind of ability it would add to your program.

And welcome to the Ranch again

 I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad: the value of filler advertising in 2021 https://coderanch.com/t/730886/filler-advertising