Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Sep 5th, 2010 | Syntax: None | Size: 3.01 KB | Hits: 26 | Expires: Never
Copy text to clipboard
  1. ok this is the HeartCal Class:
  2.  
  3.  
  4. package eadeszMod1;
  5.  
  6. public class HeartCal
  7. {
  8.         String firstName;
  9.         String lastName;
  10.         int age;
  11.         int month;
  12.         int day;
  13.         int year;
  14.         double mhr;
  15.         double thr1;
  16.         double thr2;
  17.        
  18.         public String getFirstName() {
  19.                 return firstName;
  20.         }
  21.         public void setFirstName(String firstName) {
  22.                 this.firstName = firstName;
  23.         }
  24.         public String getLastName() {
  25.                 return lastName;
  26.         }
  27.         public void setLastName(String lastName) {
  28.                 this.lastName = lastName;
  29.         }
  30.         public int getAge() {
  31.                 return age;
  32.         }
  33.         public void setAge(int age) {
  34.                 this.age = age;
  35.         }
  36.         public int getMonth() {
  37.                 return month;
  38.         }
  39.         public void setMonth(int month) {
  40.                 this.month = month;
  41.         }
  42.         public int getDay() {
  43.                 return day;
  44.         }
  45.         public void setDay(int day) {
  46.                 this.day = day;
  47.         }
  48.         public int getYear() {
  49.                 return year;
  50.         }
  51.         public void setYear(int year) {
  52.                 this.year = year;
  53.         }
  54.         public double getMhr() {
  55.                 double mhr = 220 - age;
  56.                 return mhr;
  57.         }
  58.         public void setMhr(double mhr) {
  59.                 this.mhr = mhr;
  60.         }
  61.         public double getThr1() {
  62.                 double Thr1 = mhr * .50;
  63.                 return thr1;
  64.         }
  65.         public void setThr1(double thr1) {
  66.                 this.thr1 = thr1;
  67.         }
  68.         public double getThr2() {
  69.                 double Thr2 = mhr * .85;
  70.                 return thr2;
  71.         }
  72.         public void setThr2(double thr2) {
  73.                 this.thr2 = thr2;
  74.         }
  75. }
  76.  
  77.  
  78. this is HeartCalTest:
  79.  
  80.  
  81. package eadeszMod1;
  82.  
  83. import java.util.Scanner;
  84.  
  85. public class HeartCalTest
  86. {
  87.         public static void main(String[] args)
  88.         {
  89.                 HeartCal cal = new HeartCal();
  90.                
  91.                 Scanner scan = new Scanner (System.in);
  92.                
  93.                 System.out.print("Enter your first name: ");
  94.                                 String firstName = scan.nextLine();
  95.                                 cal.setFirstName(firstName);
  96.                                
  97.                 System.out.print("Enter your last name: ");
  98.                                 String lastName = scan.nextLine();
  99.                                 cal.setLastName(lastName);
  100.                                
  101.                 System.out.print("Enter your birth month(mm): ");
  102.                                 int month = scan.nextInt();
  103.                                 cal.setMonth(month);
  104.                                
  105.                 System.out.print("Enter the day you were born(dd): ");
  106.                                 int day = scan.nextInt();
  107.                                 cal.setDay(day);
  108.                                
  109.                 System.out.print("Enter your birth year(yyyy): ");
  110.                                 int year = scan.nextInt();
  111.                                 cal.setYear(year);
  112.                
  113.                        
  114.                 System.out.print("Enter your age: ");
  115.                 int age = scan.nextInt ();
  116.                 cal.setAge(age); // this set the age in the cal object;
  117.  
  118.         System.out.printf("\nName: %s %s",
  119.                         cal.getFirstName(),
  120.                         cal.getLastName());
  121.                
  122.         System.out.printf("\nBirthday: %d/%d/%d",
  123.                         cal.getMonth(),
  124.                         cal.getDay(),
  125.                         cal.getYear());
  126.        
  127.         System.out.printf("\nYour Maximum Heart Rate is: %.2f",
  128.                 cal.getMhr(),
  129.                 cal.setMhr(mhr));
  130.        
  131.         System.out.printf("\nYour target heart range is: %.2f - %.2f",
  132.                         cal.getThr1(),
  133.                         cal.getThr2());
  134.         }
  135.  
  136. }
  137.  
  138. ---------------------------------------------------------------------------------------------
  139. If you look at the second to last method in HeartCalTest, where I have cal.setMhr(mhr)); its saying mhr can not be resolved.