The program should do the following:
Write a method called getheartRate that takes no parameters and returns an int (heartRate). This method prompts the user for the patient's heart rate, reads their input from the command line, and returns this value.
Write a method called checkHeartRate that takes an int parameter (the heart rate) and returns a String (result). If the heart rate is above 100, return the value "High". If the heart rate is below 60, return the value "Low". Otherwise return "Normal".
Write a method called printHRResult that takes a String parameter, which is the result from the method checkHeartRate. Print this value to the command line.
Call all three methods from the main method using appropriate parameter passing.
So far I have:
public class UnitSixInClassFall2018 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
UnitSixInClassFall2018 u = new UnitSixInClassFall2018();
u.getHeartRate();
System.out.println();
Scanner scan = new Scanner(System.in);
u.checkHeartRate(0);
// END MAIN
}
public int getHeartRate(){
System.out.print("Please enter your heart rate: ");
Scanner scan = new Scanner(System.in);
int heartRate = scan.nextInt();
return 0;
}
public void checkHeartRate(int heartRate){
if (heartRate > 100) {
String result = "High";
}
else if (heartRate < 60) {
String result = "Low";
}
else {
String result = "Normal";
}
}
public String printHRResults(String result) {
System.out.print("Your hear rate is " + result + ".");
return result;
}
}
When this is run, all that is output is "Please enter your heart rate: ". Once I enter an integer, the program ends. What is being done incorrectly?