Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In JAVA please! 5. The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This
In JAVA please!
5. 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=655+(4.3 weight in pounds )+(4.7 height in inches )(4.7 age in years ) The calories needed for a man to maintain his weight is: BMR=66+(6.3 weight in pounds )+(12.9 height in inches )(6.8 age in years ) A typical chocolate bar will contain around 230 calories. Write a method 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 one's weight for both a woman and a man of the input weight, height, and age. 6. Write a method that reads three strings from the keyboard. Although the strings are in no particular order, display the string that would be second if they were arranged lexicographically. 7. Write a method that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Notes: This code requires a three-way selection statement and gives more practice with string methods. The case statement can be used since the control expression is a single character. It may be instructive to show the code using if/else, instead, and compare them for readability. 8. Write a method that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12 (January is 1 ). The day value dd must be from 1 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. February has 28 days except for leap years when it has 29 . The remaining months all have 31 days each. A leap year is any year that is divisible by 4 but not divisible by 100 unless it is also divisible by 400 . Notes: This project provides an opportunity to introduce format checking. The solution uses case logic in combination with compound Boolean expressions. 9. Repeat the calorie counting program from problem 5 in a new method. This time ask the user to input the string "M" if the user is a man and "W" if the user is a woman. Use only the male formula to calculate calories if " M " is entered and use only the female formula to calculate calories if "W" is entered. Output the number of chocolate bars to consume as beforeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started