My home work is: Need to calculate how many bars of choco to maintain woman & man's BMR. See my program below. I want to change the final output without so many decimal points but round it up or you have better string format to advise me. Been stressed with this & another for past 2 nights. Please cut me some slack, i have no programming background. Please also try not to be curt by asking me to unplug my computer & write it on a piece of paper better, as suggested from a 'friendly' programming green horn from a previous post. I am not asking you to do my homework either, just guidance or examples. Thank you. I also understand that there are formats for strings, substring, characters etc. Just don't know how to use them correctly. Thank you.
Out put is: Enter weight in lbs:
Enter height in inches:
Enter age in years:
BMR for woman is: 1033.15
BMR for man is: 655.95
A typical Chocolate Bar contains about 230 calories
No. of Chocolate Bars consumed to maintain your weight:
DecimalFormat df = new DecimalFormat("###.##");
System.out.println(Double.valueOf(df.format(BMRw / choco)));
System.out.println(Double.valueOf(df.format(BMRm / choco)));
From the above you will get the output in this format "10.00 or 10.11" etc, no matter how many digits you have after the decimal point
Sarah Tod wrote:Came out nothing. What's wrong with it?
We don't do that. We will help you figure it out yourself, but nobody here is going to just give you an answer.
"Came out nothing" - so...it printed nothing? no text of any kind? you saw this:
It didn't ask you to enter a weight or height?
Then something else is going on....
or DID it come out with SOMETHING, just not what you WANTED?
Programming requires you to be extremely precise in what you say. We can assume we know what you mean, but there is almost a 100% certainty we'd be wrong. So most of us won't bother. Unless you tell us what happened, and what you expected to happen, there is nothing we can do.
Further...you've been given 3-4 suggestions on what to change. You have probably implemented some of them...but unless we can see your current code you are running, we have no way to know what it is doing.
Sarah Tod wrote:Thank you for your help. I resolved it. However, i find that there are too many comments vs showing samples from most people. Not exactly helpful.
This site is intended to guide you toward finding your own solution. Often times that consists of explaining an approach rather than showing code. In some cases, it may be useful to show an example that's similar to what you're trying to do, and then let you figure out how to adapt it to your specific case. However, in most cases, you're given enough information about the nature of the approach that you can use that to search for examples yourself.
There's a strong philosophy here of giving you just enough information to get you pointed in the right direction, and that's what some of the posts in this thread are doing. The ones that provide code for you to copy and paste are the least helpful.
I do some how believe geeks have low EQ now.
Comments like that are personal attacks, and will, at the very least, discourage people from helping you. Continuing to make those kinds of remarks will get your account locked.