Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Screenshot of Tester class where the error is and I will paste the code for the Domain just in case. Most of the tasks are

Screenshot of Tester class where the error is and I will paste the code for the Domain just in case. Most of the tasks are completed but for some reason my code does not work.

Use the attached zip file containing a skeleton of a domain class called Person, and a skeleton of a driver class called BodyMassIndex. 1. Complete the Person domain class by: a. finishing the constructor b. defining the getters and setters for all the instance variables c. defining the toString method d. defining the calculateBMI method according to the formula provided in the comments of the skeleton

2. Complete the BodyMassIndex driver class by: a. defining the createPersonObject method according to the comments in the skeleton b. defining the displayBMI method according to the comments in the skeleton

When the program runs, the output should look like this:

[dialog with user:]

What is your first name? How much do you weigh (in pounds)? How tall are you (in inches)?

package bodymassindex;

public class Person { private String firstName; private double heightInches; private double weightPounds; private double BMI; public Person (String aFirstName, double aHeightInches, double aWeightPounds, double aBmi) { this.firstName = aFirstName; this.heightInches = aHeightInches; this.weightPounds = aWeightPounds; this.BMI = aBmi; } public String getFirstName() { return firstName; } public double getHeightInches() { return heightInches; } public double getWeightPounds() { return weightPounds; } public double getBmi() { return BMI; } //etc. //Create all the setters for the attributes here: public void setFirstName(String aFirstName) { firstName = aFirstName; } public void setHeightInches(double aHeightInches) { heightInches = aHeightInches; } public void setWeightPounds(double aWeightPounds) { weightPounds = aWeightPounds; } public void setBmi(double aBmi) { BMI = aBmi; } public String toString() { return "Name: " + firstName + " "+ "Height: " + heightInches + "inches " + "Weight: " + weightPounds + "pounds " + "BMI: " + BMI; } public void calculateBMI() { //put the formula BMI = (weightPounds / (heightInches * heightInches)) * 703; } }

image text in transcribedimage text in transcribed

package bodymassindex; 7 E import java.util.Scanner; F /** * @author cristy public class Body Mass Index { public static Person anyPerson; * @param args the command line arguments public static void main(String[] args) createPersonObject(); displayBMI(); public static void createPersonObject() q //Ask user for their first name, height in inches, and weight in pounds. String firstName; double height; double weight; //Scanner and then ask user for information & store it in these local variables. Scanner keyboard = new Scanner(System.in); System.out.println("What is your first name: "); firstName = keyboard.nextLine(); System.out.println("What is your height: "); height = keyboard.nextDouble(); System.out.println("What is your weight: "); weight = keyboard.nextDouble(); //Create a Person object and store it in the static variable, anyPerson //any person = new ... anyPersone.new. Person(firstName...height weight); 48 public static void displayBMI () 49 bodymassindex.Body MassIndex> createPersonObject> //Create a Person object and store it in the static variable, anyPerson //any person = new .. anyPecson = new Person(firstName, height weight); public static void displayBMI) //Call the method in the any person object that calculates BMI any Person.calculateBMI(); //Display the BMI of the any person object. System.out.println(any Person); //Display the appropriate message to the user, depending on //the following ranges: if(any Person.getBmi() =18.5 && any person.getBmi()= 25 && anyPerson.getBmi() createPersonObject>

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

More Books

Students also viewed these Databases questions

Question

Why is executive onboarding for external hires so difficult?

Answered: 1 week ago

Question

1. What is perception?

Answered: 1 week ago