Question: Please include all parts of the program. Write a single program in a single Java class that does the following: 1) Create code that allows
Please include all parts of the program.
Write a single program in a single Java class that does the following: 1) Create code that allows the user to input their weight in pounds, height in inches, and age in years. The program should then output the number of chocolate bars that should be consumed to maintain ones weight for both a woman and a man of the input weight, height, and age. This code needs to use double floating point math, and the numeric output should not contain more than 2 decimal places. Notes:
- The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This is called your basal metabolic rate, or BMR.
- The calories needed for a woman to maintain her weight is:
- BMR(woman) = 655 + (4.3 x weight in pounds) + (4.7 x height in inches) (4.7 x years in age)
- The calories needed for a man to maintain his weight is:
- BMR(man) = 66 + (6.3 x weight in pounds) + (12.9 x height in inches) (6.8 x years in age)
- A typical candy bar contains 230 calories.
2) Accept a sentence from the user, via the keyboard. Move the first word of the sentence to the end of the sentence. Remove the capitalization from that word and capitalize the new first word of the sentence.
Notes:
- Here you will probably need to use the Scanner methods next() and nextLine() to retrieve the first word and the rest of the sentence from the input stream.
- You can then use the String methods substring(int startIndex), and substring(int startIndex, int endIndex) to change and pick apart the Strings.
- Explore the use to the String methods toUpperCase() and toLowerCase() to change letter case, and concat(String myString) to put it all together again.
3) Accept from the keyboard a four character string and then display it vertically.
Notes:
- For this one, you should use myString.charAt(index). Where myString is the name of the string holding the user input of a four character string. Index is the string index of the character you want to copy from the string.
Sample Run: Please enter your height: 68 Please enter your weight: 165 Please enter your age: 24 If you are a man you would need 1812.7 calories, or 7.88 candy bars. if you are a woman you would need 1566.6 calories, or 6.81 candy bars. Please enter a sentence. Java is the best language I have rearranged that sentence to read: Is the best language java Please enter four characters 1001 1 0 0 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
