+ 1

What is wrong here?

public class Program { public static void main(String[] args) { import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner agee = new Scanner(System.in); System.out.println(agee.nextint()); } } if(agee <= 0) { System.out.println("Error"); } else if(agee <= 16) { System.out.println("Too Young"); } else if(agee < 100) { System.out.println("Welcome!"); } else { System.out.println("Really?"); } } }

29th Nov 2018, 8:30 AM
H T
H T - avatar
4 Antworten
+ 8
Booleans and Conditional Statements https://code.sololearn.com/WHv1hxlN7Dhf/?ref=app
29th Nov 2018, 8:59 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 5
https://code.sololearn.com/cvsZnLOhh3a9/?ref=app
29th Nov 2018, 8:38 AM
Rstar
Rstar - avatar
+ 2
I guess you are trying to implement inner class import java.util.Scanner; public class Main { class MyInnerClass { public void displayMsg() { Scanner input=new Scanner(System.in); System.out.print("enter the age : "); int age=input.nextInt(); if(age<=0) { System.out.print("Error"); } else if(age<=16) { System.out.print("Too Young"); } else if(age<100) { System.out.print("Welcome!"); } else { System.out.print("Really?"); } } } public static void main(String args[]) { Main ref=new Main(); MyInnerClass ref2=ref.new MyInnerClass(); ref2.displayMsg(); } }
29th Nov 2018, 12:04 PM
Rishi Anand
Rishi Anand - avatar
0
you should use nextInt not nextint
29th Nov 2018, 1:04 PM
Souvik Bera
Souvik Bera - avatar