Define a class with properties and methods for a person

Assignment Help JAVA Programming
Reference no: EM131374078

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.

Reference no: EM131374078

Questions Cloud

Degrees of dominance : What are the three degrees of dominance and briefly what happens in each.
How would you design a cell membrane : How would you design a cell membrane that would allow you to move more material through the membrane faster without taking more space?
List some types of oil pump problems : How can a leak in the fuel suction line cause no oil to be delivered to the pump?
Why do you think walmart was successful in mexico : Do you think Walmart could translate its merchandising strategy wholesale to another country and succeed? If not, why not?- Why do you think Walmart was successful in Mexico.
Define a class with properties and methods for a person : Problem Summary Suppose you wanted to modify your Health Assistance Calculator from Java programming assignment 3, to make it more versatile. Define a class with properties and methods for a person.
What problems can arise from an oversized oil storage tank : What is a disadvantage to direct venting an oil-fired furnace?
Evaluate your current use of perceived coping mechanisms : Evaluate your current use of perceived coping mechanisms. What ways do you most commonly use and why? Where or how did you learn to use these coping mechanisms to deal with stress
Is the wrc right to argue that the fla is a tool of industry : Should Nike be held responsible for working conditions in foreign factories that it does not own, but where subcontractors make products for Nike?
What is the function of an oil safety valve : What measurements should be taken when setting up a new oil furnace?

Reviews

Write a Review

JAVA Programming Questions & Answers

  If you are using the blackboard mobile learn app please

if you are using the blackboard mobile learn app please click view in browser. technical project address bookthis

  Create a web page that displays the default information

CSCI 3300 Assignment: Create a web page that displays the default information. The initial page and related outputs should look like the examples shown below.

  Correct example of inheritance

Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild

  standard graph with four quadrant

Write a program in java that asks the user for values of x and y, and displays the point as an ordered pair along with a message that describes where that point falls on the standard graph with four quadrant.

  Designing a program with a while loop

The section entitled "In the Spotlight", "Designing a program with a while loop" describes the requirements for a project at Chemical Labs, Inc. Write a letter to the Director of Engineering that describe your concerns, if any, regarding these re..

  Where the computer stores the list of exceptions

The call stack is where the computer stores the list of exceptions. Overloaded methods have the same name and parameter lists

  Write a class that reads a file

In java, write a class that reads a file and outputs a list of the unique words in the file and the number of times each unique word occurs.Hint: use a HashMap with keys being the words and values being integer counts associated with the words.

  Nailpolish inventory in java

In addition, the GUI should include a button that allows the user to move to the first item, the previous item, the next item, and the the last item in the inventory

  Define variables constructors and methods

It defines variables, constructors, and methods. The second class is ClassClient. In ClassClient, the constructor for FirstClassOOPS is called.

  Write down java console application to add new student

Write down java console application presents the following menu. Add new student and scores in Biology, Physics and chemistry Search for a given student.

  Write program in java for total amount of customer-s order

Write down program in Java which would ask for clerk to enter total amount of customer's order. Program will then compute seven percent (7%) sales tax.

  Write java program to read present basic hourly wage

Write down a java program which will input 1. Read present basic hourly wage. Read in workers fist name and socond name.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd