0
Can you hep me to find error
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package age; public class Age { public static void main(String args[]) { System.out.println("Age group: "); int a=in.nextInt(); in.close(); if (a>=0 && a<=35) { System.out.println("youth"); } else if (a>=36 && a<=60) { System.out.println("middle Age"); } else if (a>=61 && a<=120) { System.out.println("old age"); } else { System.out.println("Invalid age"); } } }
1 Odpowiedź
+ 6
I think there is no need to write this line:
package age;
Next, you have to import java.util.*; at the beginning.
Then, you have to write "Scanner in= new Scanner(System.in); " this line for taking input,inside main() function since you have used in.nextInt(); for taking input.
Maybe your code should be like this:
https://code.sololearn.com/cA45A23600a6