Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- * Write a description of class HeartRates here.
- * This Program will establish the age of a person. From this age the program will calculate the Maximuim
- * Heart Rate and Heart Rate range,
- * @author Michael Young
- * @version (October 1, 2011)
- */
- public class HeartRates
- {
- // instance variables
- public String FirstName;
- public String LastName;
- public int bday;
- public int bmonth;
- public int byear;
- public int cyear;
- private int age;
- private double maxiHR;
- private double targetminiHR;
- private double targetmaxiHR;
- //** Starting to attempt to define the constructor.
- public HeartRates(String inputFirstName, String inputLastName, int inputBirthDay, int inputBirthMonth,
- int inputBirthYear, int inputCurrentYear)
- // Constructor with no arguments
- {
- FirstName = inputFirstName;
- LastName = inputLastName;
- bday = inputBirthDay;
- bmonth = inputBirthMonth;
- byear = inputBirthYear;
- cyear = inputCurrentYear;
- }
- ///** Setting up constructor with arguments.
- public HeartRates ()
- {
- FirstName = "Michael";
- LastName = "Young";
- bday = 2;
- bmonth = 8;
- byear = 1989;
- cyear = 2011;
- }
- /// Sets
- public void setFirst(String inputFirstName)
- {
- FirstName = inputFirstName;
- }
- public void setLast(String inputLastName)
- {
- LastName = inputLastName;
- }
- public void setbday(int inputBirthDay)
- {
- bday = inputBirthDay;
- }
- public void setbmonth(int inputBirthMonth)
- {
- bmonth = inputBirthMonth;
- }
- public void setbyear(int inputBirthYear)
- {
- byear = inputBirthYear;
- }
- public void setcyear(int inputCurrentYear)
- {
- cyear = inputCurrentYear;
- }
- //gets
- public String getFirst()
- {
- return FirstName;
- }
- public String getLast()
- {
- return LastName;
- }
- public int getbday()
- {
- return bday;
- }
- public int getbmonth()
- {
- return bmonth;
- }
- public int getbyear()
- {
- return byear;
- }
- public int getcyear()
- {
- return cyear;
- }
- /// Methods for calculating
- public int calculateage()
- {
- age = cyear-byear;
- return age;
- }
- public double maximumHR()
- {
- maxiHR = 220 - age;
- return maxiHR;
- }
- public double targetminimumhr()
- {
- targetminiHR = maxiHR * .5;
- return targetminiHR;
- }
- public double targetmaximumhr()
- {
- targetmaxiHR = maxiHR * .85;
- return targetmaxiHR;
- }
- public void main(String arg[]){
- String FirstName;
- String LastName;
- int bday;
- int bmonth;
- int byear;
- int cyear;
- Scanner input = new Scanner(System.in);
- System.out.print( "Enter First Name: ");
- FirstName = input.next();
- System.out.print ("Enter Last Name: ");
- LastName = input.next();
- System.out.print ("Enter Birthyear: ");
- byear = input.nextInt ();
- System.out.print ("Enter Birth Month: ");
- bmonth = input.nextInt ();
- System.out.print ("Enter Birth Day: ");
- bday = input.nextInt();
- System.out.print ("Enter Current Year: ");
- cyear = input.nextInt();
- HeartRates a = new HeartRates();
- System.out.println("Patient's Name: " + FirstName() + LastName());
- System.out.println("Patient's Age: " + a.calculateage());
- System.out.println("Patients Maximum Heart Rate:" + a.maximumHR());
- System.out.println("Patients Target Heart Rate:" + a.minimumHR() " - " a.maximumHR());
- }
- }
Add Comment
Please, Sign In to add comment