• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with Simple Home Work

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry im new to this
but this is what i got so far

2.1






3.1





3.2

 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic