- ok this is the HeartCal Class:
- package eadeszMod1;
- public class HeartCal
- {
- String firstName;
- String lastName;
- int age;
- int month;
- int day;
- int year;
- double mhr;
- double thr1;
- double thr2;
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public int getMonth() {
- return month;
- }
- public void setMonth(int month) {
- this.month = month;
- }
- public int getDay() {
- return day;
- }
- public void setDay(int day) {
- this.day = day;
- }
- public int getYear() {
- return year;
- }
- public void setYear(int year) {
- this.year = year;
- }
- public double getMhr() {
- double mhr = 220 - age;
- return mhr;
- }
- public void setMhr(double mhr) {
- this.mhr = mhr;
- }
- public double getThr1() {
- double Thr1 = mhr * .50;
- return thr1;
- }
- public void setThr1(double thr1) {
- this.thr1 = thr1;
- }
- public double getThr2() {
- double Thr2 = mhr * .85;
- return thr2;
- }
- public void setThr2(double thr2) {
- this.thr2 = thr2;
- }
- }
- this is HeartCalTest:
- package eadeszMod1;
- import java.util.Scanner;
- public class HeartCalTest
- {
- public static void main(String[] args)
- {
- HeartCal cal = new HeartCal();
- Scanner scan = new Scanner (System.in);
- System.out.print("Enter your first name: ");
- String firstName = scan.nextLine();
- cal.setFirstName(firstName);
- System.out.print("Enter your last name: ");
- String lastName = scan.nextLine();
- cal.setLastName(lastName);
- System.out.print("Enter your birth month(mm): ");
- int month = scan.nextInt();
- cal.setMonth(month);
- System.out.print("Enter the day you were born(dd): ");
- int day = scan.nextInt();
- cal.setDay(day);
- System.out.print("Enter your birth year(yyyy): ");
- int year = scan.nextInt();
- cal.setYear(year);
- System.out.print("Enter your age: ");
- int age = scan.nextInt ();
- cal.setAge(age); // this set the age in the cal object;
- System.out.printf("\nName: %s %s",
- cal.getFirstName(),
- cal.getLastName());
- System.out.printf("\nBirthday: %d/%d/%d",
- cal.getMonth(),
- cal.getDay(),
- cal.getYear());
- System.out.printf("\nYour Maximum Heart Rate is: %.2f",
- cal.getMhr(),
- cal.setMhr(mhr));
- System.out.printf("\nYour target heart range is: %.2f - %.2f",
- cal.getThr1(),
- cal.getThr2());
- }
- }
- ---------------------------------------------------------------------------------------------
- If you look at the second to last method in HeartCalTest, where I have cal.setMhr(mhr)); its saying mhr can not be resolved.
