Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M92183913

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As