Question
Class Name and class Healthprofile, they have the same void displayInfo() in each classes. what should I add in class Name- void displayInfo() and Healthprofile()
Class Name and class Healthprofile, they have the same void displayInfo() in each classes.
what should I add in class Name- void displayInfo() and Healthprofile() - void displayInfo()
-------------------------full code
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
enum Month {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
class Date{
private int day;
private Month month;
private int year;
//default constructor
public Date()
{
this.day = 1;
this.month = Month.Jan;
this.year = 2023;
}
//other constructor
public Date (int day, Month month, int year)
{
this.day = day;
this.month = month;
this.year =year;
}
//copy constructor
public Date(Date d)
{
this(d.day, d.month, d.year);
}
// Accessor methods
public int getDay()
{
return day;
}
public Month getMonth()
{
return month;
}
public int getYear()
{
return year;
}
//mutator methods
public void setDate(int day, Month month, int year)
{
this.day = day;
this.month = month;
this.year = year;
}
}
class Height
{
private int feet;
private int inches;
//default constructor
public Height()
{
this.feet = feet;
this.inches = inches;
}
//other constructor
public Height(int feet, int inches)
{
this.feet = feet;
this.inches = inches;
}
//copy constructor
public Height(Height h)
{
this(h.feet, h.inches);
}
// Accessor methods
public int getFeet()
{
return feet;
}
public int inches()
{
return inches;
}
// Mutator method
public void setHeight(int feet, int inches)
{
this.feet = feet;
this.inches = inches;
}
// feet to meters
public double getMeters()
{
double meters = feet * 0.3048;
return meters;
}
// Convert inches to meters
public double getCentimeters()
{
double centimeters = inches * 0.0254;
return centimeters;
}
public double getHeightInMeter()
{
double heightinmeter = getMeters() + getCentimeters();
return heightinmeter;
}
}
class Name {
private String firstName;
private String lastName;
public Name(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
public Name(Name n)
{
this(n.firstName, n.lastName);
}
// Accessor methods
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
public void setName(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
public void displayInfo()
{
System.out.printf("%nName: %s, %s%n", firstName, lastName);
//System.out.printf("Date of birth: %d %s %d %n" );
}
}
class HealthProfile{
private Name name;
private Date dob;
private Height h;
private double weight;
private int currentYear;
//constuctor
public HealthProfile(Name name, Date dob, Height h, double weight, int currentYear)
{
this.name = name;
this.dob = dob;
this.h = h;
}
public HealthProfile(HealthProfile hr)
{
this(hr.name, hr.dob, hr.h, hr.weight, hr.currentYear);
}
public Name getName()
{
return hr.name;
}
public void setName(Name name)
{
this.name = name;
}
public Date getDOB()
{
return hr.dob;
}
public Height getHeight()
{
return hr.h;
}
public double getweight()
{
return hr.weight;
}
public void setDOB(Date dob)
{
this.dob = dob;
}
public void setHeight(Height h)
{
this.h = h;
}
public int getCurrentYear()
{
return hr.currentYear;
}
public void setCurrentYear(int currentYear)
{
this.currentYear = currentYear;
}
public int getAge()
{
int age = currentYear - dob.getYear();
return age;
}
public int getMaximumHeartRate()
{
int maxHR = 220 - getAge;
return maxHR;
}
public doube getMinimumTargetHeartRate()
{
double minTHR = getMaximumHeartRate()*0.5;
return minTHR;
}
public double getMaximumTargetHeartRate()
{
double maxTHR = getMaximumHeartRate() * 0.85;
return maxTHR;
}
public double getBMI()
{
double bmi = weight / (h.getHeightInMeter() *h.getHeightInMeter());
return bmi;
}
public void displayInfo()
{
}
}
display looks this and i have input.txt file
Name: Mohamed Ali, Bin Abdullah Date of birth: 15 Oct 1951 Your weight: 63.5kg Your height: 5 feet 6 inches; equivalent to: 1.68 meter Current year: 2022 Your age: 71 years old Clinic analysis, base on your age: 1. Your maximum heart rate is 149 2. Your minimum target heart rate is 74.50 3. Your maximum target heart rate is 126.65 Your BMI 22.6 Weight category Range Underweight / too low Below 18.5 Healthy range 18.525 Overweight 2530 Obese 3035 Severe Obesity 3540 Morbid Obesity Over 40Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started