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

  Develop a form based front end for a class management

In this assignment, students will develop a form based front end for a class management system and a database using a combination of JDBC commands, SQL, and Swing GUI components to allow users to query, insert, update and delete records using a si..

  Depicts a model for recording flight and passenger

This assignment requires you to design, implement and test a program using Java features from the first half of the subject content. You are required to implement in Java all the classes presented in the conceptual model according the specificatio..

  Concepts of interfaces and inheritance

In this assignment we will work with the concepts of interfaces and inheritance. We will make use of a extends to create an inheritance hierarchy, and use implements to implement an interface that allows properties to be added to objects at run-ti..

  Overview in this assignment you are provided with an

overview in this assignment you are provided with an interface that contains a generic type.you are asked to create two

  Class named stock to model a stock

Write a class named Stock to model a stock. The properties and methods of the class are shown in Figure 6.22. The metho changePercent computes the percentage of the change in the current vs. the previous closing price.

  Using your musicalinstrument class

Finally, create a Java test class that simulates using your MusicalInstrument class.  In your test class you should at a minimum: a) Construct 4 instances of your instrument, b) tune your instruments, c) print the name of your instrument d) print ..

  Develop a prototype based on the user specifications

Develop a prototype based on the user specifications and the design proposed by your team. Your prototype will focus on only maintaining information for packs and deliveries for calculating delivery charges and reimbursement

  Write the complete code for a public java class

Write the complete code for a public Java class called Change Machine that can hold nickels, dimes and quarters. Include a private instance variable to hold each type of coin that the machine hols.

  Java application which creates bank records

Write down a java application which creates 10000 bank records and the allow user ti enter a balance and customer account info. using a an account number.

  Write a point class that represents points on an x y axis

write a point class that represents points on an x y axis. the data members should be doubles x and y plus an int value

  Implementing the add and remove methods

Prepare a class that maintains the top 10 scores for a game application, implementing the add and remove methods but using a doubly linked list instead of an array. Program has to be written in java

  Implement a simple number guessing game using html forms

Your assignment is to implement a simple number guessing game using HTML forms and a Java servlet. The HTML page should introduce the game and provide a form for the user to guess a number on. The servlet should use an HTTP session object to store..

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