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

  Loops and files

Convert an algorithm using control structures into Java and write a while loop

  Write a program that asks for purchase price

Write a program that asks for purchase price and to calculate, state sales tax, county sales tax and then display purchase price, both sales tax amount and then the total.

  Define a function name classify that takes a string as input

The function should return a string value, either "word" or "phrase", depending on whether the input string contains any spaces

  How to compile and debug your work

You will be writing a Java program to allow people to play the 24-puzzle (the obvious variant where the frame is 5x5) puzzle) in a text based context. My goal is that you recall how to enter programs (probably using jGrasp), how to write a small/s..

  Assume the existence of a function copyvillian

Show how you would use the above copyVillian function to create a copy of sharpay called sharpaysMoreEvilTwin.

  Design implement test and debug a program with a jframe

design implement test and debug a program with a jframe that allows the user to enter a series of contacts names ages

  What is the method for broadcasting an intent

What is the method for broadcasting an Intent? What is the method for saving the Activity state? What is the method for retrieving application assets? What is the method for accessing application preferences?

  Describe the swing applet life cycle

Describe the swing applet life cycle. Create a swing applet that displays the date and time in a JTextField with the JLabel "Today is" when the user clicks a JButton

  Project amount of total sales

Write a program called sales_prediction.js, that displays the profit based on the project amount of total sales for the year. Use a literal value of $2,500,000 for the projected total sales amount. Display the profit amount formatted to two decima..

  Build a flowchart that models a complete java program

Using a flowcharting tool of your choice, build a flowchart that models a complete Java program called PasswordChecker that gets a String from the user at the command line and checks whether the String, called password, conforms to the password..

  Create a class named student that has three member variables

Create a class named Student that has three member variables

  Explain how to declare and manipulate data in arrays

Please respond to all of the following prompts: Explain how to declare and manipulate data in arrays. Explain the meaning of "array index out of bounds".

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