The exception in main | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
7 Answers
+ 4
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in) ; System. out. println ("enter any age"); int age; age=sc.nextInt(); if(age <= 0) { System.out.println("Error"); } else if(age <= 16) { System.out.println("Too Young"); } else if(age < 100) { System.out.println("Welcome!"); } else { System.out.println("Really?"); } } }
23rd Mar 2020, 4:03 AM
Cmurio
Cmurio - avatar
+ 3
import java.util.Scanner; class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in); System.out.println("enter any no"); int a; a=sc.nextInt(); if (a>20){ System.out.println ("adult"); }else{ System.out.println ("too young"); } } }
23rd Mar 2020, 4:00 AM
Cmurio
Cmurio - avatar
+ 3
considerations: the code marked error due to the spaces you made in each word of each line. For example: incorrect: import java. util. Scanner ; correct: import java.util.Scanner;
23rd Mar 2020, 4:02 AM
Cmurio
Cmurio - avatar
+ 2
correct : Scanner sc=new Scanner (System.in);
23rd Mar 2020, 4:28 AM
Cmurio
Cmurio - avatar
+ 2
Without SPACE bro
23rd Mar 2020, 4:30 AM
Cmurio
Cmurio - avatar
0
Its not working
23rd Mar 2020, 4:22 AM
Akash Deep Deep
Akash Deep Deep - avatar
0
I have written same
23rd Mar 2020, 4:29 AM
Akash Deep Deep
Akash Deep Deep - avatar