Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Simple Home Work  RSS feed

 
maxwell hunter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im learning java, but i like to learn it without someone breathing over my neck!

im still new but my teacher wont understand.

please see the attachment

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)

Please Help!
Screen-Shot-2015-10-16-at-6.03.09-PM.png
[Thumbnail for Screen-Shot-2015-10-16-at-6.03.09-PM.png]
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12541
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

People here WANT to help you, but you have to help us help you.

What have you got so far? Can you compile and run a simple "helloWorld.java" program? Please be specific.
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The formula for BMI is
10000 × w ÷ h²
Yu appear to have missed out a division sign in copying.
 
maxwell hunter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry im new to this
but this is what i got so far

2.1






3.1





3.2

 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Liutauras Vilda
Marshal
Posts: 4624
316
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!