Open mandatoryting opened 3 years ago
package com.company.ROADMEN; import java.util.Scanner;
public class q3 { public static void main(String[] args) { Scanner userInput = new Scanner(System.in); int age = 0; char gender =' '; int hrRest = 0; String sport = " ";
System.out.println("Please enter your resting hart rate");
hrRest = userInput.nextInt();
System.out.println("Please enter your age");
age = userInput.nextInt();
userInput.nextLine();
System.out.println("Please enter your gender(m or f)");
gender = userInput.next().charAt(0);
if (age <= 0) {
System.out.println("please enter your age again!!");
age = userInput.nextInt();
}
if (gender != ('m' || 'f')) {
System.out.println("please re-enter your gender");
gender = userInput.next().charAt(0);
}
if (hrRest <=0) {
System.out.println("please re-enter resting heart rate");
hrRest = userInput.nextInt();
}
int hrMax = 220 - age;
double vo2Max = 15 * (hrMax/ hrRest);
while (age > 0 && hrRest > 0 && gender == 'm' || gender == 'f')
if (age <= 0) {
System.out.println("please enter your age again!!");
age = userInput.nextInt();
}
if (gender != 'f' && gender != 'f') {
System.out.println("please re-enter your gender");
gender = userInput.next().charAt(0);
}
if (hrRest <=0) {
System.out.println("please re-enter resting heart rate");
hrRest = userInput.nextInt();
}
System.out.println("your eligable sports are:");
if (gender == 'm') {
if (vo2Max >= 40 && vo2Max <= 60 && age >= 18 & age <= 30)
System.out.println("Basketball");
if (vo2Max >= 62 && vo2Max <= 74 && age >= 18 && age <= 26)
System.out.println("Bicycling");
if (vo2Max >= 55 && vo2Max <= 67 && age >= 18 && age <= 26)
System.out.println("Canoeing");
if (vo2Max >= 52 && vo2Max <= 58 && age >= 18 && age <= 22)
System.out.println("Gymnastics");
if (vo2Max >= 50 && vo2Max <= 70 && age >= 10 && age <= 25)
System.out.println("Swimming");
}
if (gender == 'f') {
if (vo2Max >= 43 && vo2Max <= 60 && age >= 18 & age <= 30)
System.out.println("Basketball");
if (vo2Max >= 47 && vo2Max <= 57 && age >= 18 && age <= 26)
System.out.println("Bicycling");
if (vo2Max >= 47 && vo2Max <= 67 && age >= 18 && age <= 26)
System.out.println("Canoeing");
if (vo2Max >= 36 && vo2Max <= 50 && age >= 18 && age <= 22)
System.out.println("Gymnastics");
if (vo2Max >= 40 && vo2Max <= 60 && age >= 10 && age <= 25)
System.out.println("Swimming");
}
}
}
I'm trying to write this code and I am getting a lot of errors can someone help me fix the errors