Question: Import java.lang.math; Math.randon ( ) 1. Create a Java Class called Dieter . The class has the following variables: : string that is the Dieters
Import java.lang.math;
Math.randon ( )
1. Create a Java Class called Dieter.
The class has the following variables:
: string that is the Dieters name
: int that is the Dieters weight in pounds
: int that is the Dieters height in inches
BMI : double that is the Body Mass Index for the Dieter
The class has the following public instance methods (all take no parameters):
: constructor that prompts the user for a name, weight and height and creates an instance of Dieter using these inputs
: randomly changes the Dieters weight
1/10 of the time it increases the weight by a random integer from 1 to 5
9/10 of the time it decreases the weight by a random integer from 1 to 10
It also prints the amount of weight lost or gained
: randomly changes the Dieters weight
1/10 of the time it decreases the weight by a random integer from 1 to 5
9/10 of the time it increases the weight by a random integer from 1 to 10
It also prints the amount of weight lost or gained
: prints a report containing the Dieters name, weight and height. Also printed is a statement for the Dieter based on the following BMI values (should include the BMI value with 2 digit after the decimal):
o Underweight: BMI is less than 18.5.
o Normal weight: BMI is 18.5 to 24.9.
o Overweight: BMI is 25 to 29.9.
o Obese: BMI is 30 or more
The class has the following private method defined and used (no parameters):
: returns a double value which is the Dieters Body Mass Index: BMI
The formula for BMI is:
703 x weight (lbs) / [height (in)]2
The class has the following private static variable:
totalWeightChange : Amount of weight lost/gained by all dieters.
The class has the following static method that takes no parameters:
: Simply returns totalWeightChange
2. Write a Java class application called Dieterapp. Dieterapp should create a Dieter.
A menu based loop will then be run with the following choices:
person: use the constructor to create a new Dieter
diet: runs the diet method
party: runs the party method
report: runs the report method
quit: ends the loop
An error message should be printed if an illegal command is entered.
The total weight change for all dieters should be displayed at the end of the run.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
