Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro to Java Programming Question, please help, would appreciate it allot. Thank youuu Preamble Body mass index (BMI) is a measure of the body's fat

image text in transcribed

image text in transcribed

image text in transcribed

Intro to Java Programming Question, please help, would appreciate it allot. Thank youuu

Preamble Body mass index (BMI) is a measure of the body's fat based on height and weight. BMI applies to adult men and women and considered a convenient rule of thumb to broadly categorize a person as underweight, normal weight, overweight, or obese based on tissue mass (muscle, fat, and bone) and height. That categorization is the subject of some debate about where on the BMI scale the dividing lines between categories should be placed. Commonly accepted BMI ranges are underweight (under 18.5 kg/m2), normal weight (18.5 to 25), overweight (25 to 30), and obese (over 30)'. For more information, please visit https://en.wikipedia.org/wiki/Body_mass_index In this assignment, you will develop a Java command-line program to compute a person's BMI based on the criteria described earlier. Requirements: 1. Your program must compile, run, and conform to the Java conventional programming rules 2. Comment your code: Place Javadoc comments for the class' definition and for each of the class' members (variables and methods) Place non-Javadoc comments for major steps in your code 3. Submit a separate source file for each of the following two classes: 1. PersonInfo - a container for the data and operations relating to a person's weight. 2. TestPersonInfo - a class which contains the main method and performs unit testing on the previous class. 3. You must use String formatters (i. e.printf(...) and String.format(...)) for printing. Your solution should NOT contain the methods print() OR println(). 4. Class PersonInfo: a. Four variables for Name (String), year of birth (Int), height (Double), and weight (Double). b. Default constructor to initialize the four variables to their default values ("" for strings and 0 for numeric). c. Non-default constructor to initialize the four variables using 4 constructor parameters. d. Accessors (setters) and mutators (getters) methods for all four variables - 8 methods in total. e calculate Age) to return the person's age. >> In order to compute the age, you will need to programmatically obtain the current year. DO NOT hard-code the current year as part of you class. Use the following Java statement to retrieve the current year: new GregorianCalendar().get(GregorianCalendar. YEAR) f. calculateBMI( ) to return the person's BMI: - bmi = weight/height? 5. Class TestBMI: Remember: Show a message string before the prompt. Using printf() ONLY Create a method called classifyBMIO; the method returns one of the following strings: "Underweight": if BMI is under 18.5 "Normal Weight": if BMI is between 18.5 and 25 "Overweight": if BMI is between 25 and 30 "Obese": if BMI is more than 30 Create an instance of class PersonInfo using the default constructor. Use the mutator methods to assign values to the class' 4 private members. The test values are shown in Figure 1. Prompt the user to enter the person's full name, year, height, and weight. These values will be used in the next step. Sample test values are shown in Figure 2. Create an instance of PersonInfo using the non-default constructor. Use the values from the previous step. Using printf(print the information such that it is formatted as shown in the example in Figure 1 and Figure 2. All leading labels should have column widths of 16 characters. Grading: Points 10 2 8 10 10 10 Item Comments (Javadoc and major steps) PersonInfo class (Compiles and runs) 4 variables Accessor and mutator methods Constructors calculate Age calculateBMIO. TestBMI class (Compiles and runs) Instance of PersonInfo using the default constructor Prompt and capture of input Setters Instance of PersonInfo using the non-default constructor Prompt and capture of input Printing person's info to command prompt from both instances Correct output 3 4 4 10 4 15 10 50 First Instance Prompts Enter person's name: John Doe Enter person's year of birth: 1991 Enter person's height in meters: 1.26 Enter person's weight in kilograms: 123.45 Figure 1: Sample Run 1 Second Instance Prompts Enter person's name: Jane Doe Enter person's year of birth: 2000 Enter person's height in meters: 1.1 Enter person's weight in kilograms: 31.9 Figure 2: Sample Run 2 1st instance Output Full Name: John Doe Age: 30 Height: 1.26 Weight: 123.45 Classification: Obese Column Width for each label is 16 characters long 2nd instance Output Full Name: Jane Doe Age: 21 Height: 1.10 Weight: 31.90 Classification: Overweight Figure 3: output of program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

Write Hund's rule?

Answered: 1 week ago