Problem summary suppose you wanted to modify your health


Assignment: Object and Instances Netbeans Program- INBOX FOR SOLUTION

Problem Summary Suppose you wanted to modify your Health Assistance Calculator from Java programming assignment 3, to make it more versatile.

You could add the following features:

· Store the data about one person in an object, and revise the calculation methods to be instance methods. This would eliminate the need to pass the person's data into the method via parameters.

· After computing the BMI, tell the person whether they are in the normal range. If not, determine whether the person would like to consider losing weight or gaining weight, and suggest a new daily caloric intake.For this program, assume that to gain or lose 1 pound in a week, a person must increase or reduce his/her calorie consumption by 3500 calories for that week. (Note that this figure is only an estimate. The actual figure will vary according to a person's leanmuscle mass.)

· When computing the daily calorie requirement, take into account the gender and activity level of the person.

Program Requirements Within this program, you must use at least one of each of the following programming constructs, where appropriate:

·if or if/else statement
·multiple alternative if statement
·nested if statement
·switch statement

Modify the program you wrote for assignment 3, as follows:

1. Define a class with properties and methods for a person.

The class will have the following private properties to store data about the person:

·weight (in kgs)
·height (in cm)
·age (in years)
·gender (char ‘m' or ‘f').

Within the class:

· Define a constructor with parameters that will pass in initial values for each data field, and will initialize their values.
· Modify the BMI calculation method to be an instance method within the new class.
· Combine the two calorie computations methods (one for men and one for women) into one instance method within the new class.

Inside the method:

o Decide which formula to use, based upon the person's gender.

o Read the person's activity level from the user, and decide which activity factor to use. The physical activity factors are: ♣ 1.2 for sedentary people ♣ 1.375 for moderately active people (light exercise 1-3 days a week) ♣ 1.55 for active people (moderate exercise 3-5 days a week) ♣

1.725 for very active people (heavy exercise 6-7 days a week).

2. Within the original class:

· Modify the display results method.

The revised method will:

o Have two parameter values passed into it: the person's BMI and daily required calories for maintenance.
o Have two local constants defined to hold the lowest and highest BMI in the normal range (18.5 and 24.9).
o Display what the normal BMI range is.
o Display what the person's BMI is, and whether it is normal, below normal, or above normal.
o Recommend an action plan based on the person's BMI.

a. If BMI is in the normal range, simply display the daily calories needed to maintain the current weight.
b. If BMI is below the normal range, ask if the person wants to try to reach the normal range.

Let them enter ‘y' or ‘n' to answer your question.

♣ If the person enters ‘y' or ‘Y', ask how many pounds they would like to gain per week and display suggested daily calories to gain that amount. ♣ Otherwise, simply display the daily calories needed to maintain weight c. If BMI is above the normal range, ask if the person wants to try to reach the normal range. Let them enter ‘y' or ‘n' to answer your question. ♣ If the person enters ‘y' or ‘Y', ask how many pounds they would like to lose per week and display suggested daily calories to lose that amount. ♣ Otherwise, simply display the daily calories needed to maintain weight

· Modify the main method to perform the following additional tasks (beyond tasks from assn 3):

o Read an additional input (the person's gender) NOTE: You may assume all user input is valid. Therefore, the program does not need to test for invalid input.

o After reading all inputs, the main method will instantiate an object of the new person class type, using the values read from the user (converted as necessary, before instantiation).

o Send messages to the new object to calculate and return the BMI and required daily calories to maintain their current weight. o Call the revised method to display the results.

Example output

This program implements a Health Assistance Calculator Given a weight, height, age, and gender, it will compute:

BMI - body mass index

Calories - needed per day to adjust or maintain weight

Please enter your weight in pounds: 190
Please enter your height in inches: 70
Please enter your age in years: 33
Please enter your gender (M/F): m

Select your activity level: 1 - sedentary 2 - moderately active (light exercise 1-3 days a week) 3 - active (moderate exercise 3-5 days a week) 4 - very active (heavy exercise 6-7 days a week)

Enter choice from above: 2

A BMI in the range of 18.5 to 24.9 is considered normal.
Your BMI is 27.3, which is above normal.
Would you like to try and reach the normal range (Y/N)? y

Please enter the number of pounds you would like to lose per week: 1
To lose 1 pound(s) per week, you should consume 2128 calories per day.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Problem summary suppose you wanted to modify your health
Reference No:- TGS02170742

Expected delivery within 24 Hours