0
Why am I not able to execute the if condition in this program? My output is just Enter your age to get maximum heart rate 60
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner myvar = new Scanner(System.in); System.out.println("Enter your age to get maximum heart rate"); int age = myvar.nextInt(); System.out.println("you have enter age as "+age); int res2=220-age; System.out.println("MHR "+res2); if(age<0){ if(age<20) { System.out.println("young "+res2); }else{ System.out.println("Stay healthy dude"+res2); } System.out.println("Error"); }myvar.close(); }
1 Odpowiedź
0
Because you mentioned in program age<0....but we cant give our age less than 0 right, so, age must be greater than 0 i.e.,age>o