I am attempting to make a heart rate calculator program. Here is a little overview of what I am trying to do.
It must use a constructor and get and set methods. It must print heart rate ranges and the user's information(age).
I am sure there are many problems with my code I am truly a beginner this is one of my first programs. Any obivous errors pointed out would help a lot.
Thank you.
// Use scanner to get inputs import java.util.Scanner; // Declare class public class HeartRates { private int Age; private int DayOfBirth; private int MonthOfBirth; private int YearOfBirth; private double MaxHeartRate; private double MinTargetHeartRate; private double MaxTargetHeartRate; private String FirstName; private String LastName; public HeartRates(_FirstName) //This is incomplete, I am very confused on the constructor concept. { FirstName = _FirstName; } // method to set age public void setAge(int n) // store age { Age = n; } // end method setAge // method to get age public int getAge() { return Age; } // method to set day of birth public void setDayOfBirth(int z) { DayOfBirth = z; } // end method setDayOfBirth // method to get day of birth public int getDayOfBirth() { return DayOfBirth; } // method to set month of birth public void setMonthOfBirth(String month) { MonthOfBirth = month; } // method to get month of birth public String getMonthOfBirth() { return MonthOfBirth; } // method to set year of birth public void setYearOfBirth(int y) { YearOfBirth = y; } // method to get year of birth public int getYearOfBirth() { return YearOfBirth; } // method to set first name public void setFirstName(String first) { FirstName = first; } // method to get first name public String getFirstName() { return FirstName; } // method to set last name public void setLastName(String last) { LastName = last; } // method to get last name public String getLastName() { return LastName; } // method that calculates and returns age public int Age () { Age = (2014 - YearOfBirth); } public int MaxHeartRate () { MaxHeartRate = 220 - Age; } public int MaxTargetHeartRate () { MaxTargetHeartRate = (MaxHeartRate*.085); } public int MinTargetHeartRate () { MinTargetHeartRate = (MaxHeartRate*0.50); } public static void main(String[] args) { System.out.print("Enter first and last name \n"); System.out.print("Enter birthdate in format xx/xx/xxxx \n"); System.out.printf("%s", getFirstName()); } }