Question
Instructions: For submission, the students should write: IPO The flowchart the source code (Java program) the output (three sets) In the source code, use comments
Instructions: |
For submission, the students should write: IPO The flowchart the source code (Java program) the output (three sets) In the source code, use comments to state your matric number, name, program, and lab assignment number
|
Questions:
Write a program to develop an interactive program that gives the user choices two choices: to calculate BMI and to calculate the BMR for the specified gender.
Develop a program that does the following:
Prompts the user to enter age, gender, weight (kg) and height (cm).
Prompts the user to enter a choice. If the user enters anything, but not 1 or 2, display the message wrong code.
In case the user chooses 1:
calculate his/her BMI(BMI=weight/height2)
If the user chooses 2:
calculate his/her BMR
BMR men = (66+(6.23 * weight in kilos) + (12.7 * height in cm) (6.8 * age in years))
BMR women = 655 + (9.6 x weight in kilos) + ( 1.8 x height in cm) - ( 4.7 x age in years )
The program then displays the BMI/ BMR result for the number of users.
Write the following methods and the main method for the program:
/* method to getAge from console and return the age */
/* method to getWeight from console and return the weight (in kg) */
/* method to getHeight from console and return the height (in cm)*/
/* method to getChoice from console and return the choice(1/2)*/
/* method to getGender from console and return the gender(f/m) female or male*/
/* method to calculate and return the BMI. Formal parameters are the weight and height (cm). Formula BMI=weight/height2 (convert height in cm to m). */
/* method to calculate and return the BMR (based on the gender). Formal parameters are the age, gender, weight and height (in cm)*/
BMR men = (66+(6.23 * weight in kilos) + (12.7 * height in cm) (6.8 * age in years))
BMR women = 655 + (9.6 x weight in kilos) + ( 1.8 x height in cm) - ( 4.7 x age in years )
/* method to display BMI output. Formal parameters are BMI, height (cm), weight(kg) */
/* method to display BMR output. Formal parameters are BMR, age, gender */
Sample output:
Enter age: 45
Enter weight (kg): 55
Enter height (cm): 156
Enter Gender (f/m): f
Enter choice (1-BMI, 2-BMR): 1
Your height is 156.00cm and weight is 55.00kg. So your BMI is 22.60
Do you want to continue?(y/n)y
*****************************************
Enter age: 55
Enter weight (kg): 66
Enter height (cm): 178
Enter Gender (f/m): f
Enter choice (1-BMI, 2-BMR): 2
Your age is 55. So your BMR is 1350.50
Do you want to continue?(y/n)y
*****************************************
Enter age: 34
Enter weight (kg): 44
Enter height (cm): 124
Enter Gender (f/m): f
Enter choice (1-BMI, 2-BMR): 3
wrong code
Do you want to continue?(y/n)n
*****************************************
Step 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