+ 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?"); } } }
4 Answers
+ 8
Booleans and Conditional Statements
https://code.sololearn.com/WHv1hxlN7Dhf/?ref=app
+ 5
https://code.sololearn.com/cvsZnLOhh3a9/?ref=app
+ 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();
}
}
0
you should use nextInt not nextint