Import java.util.scanner;//introduces a class
public class T3 {
public static void Main (string[] args) {
Console input
Console output
System.out.print ("Please Enter,:");
Input
Scanner Scan System input
Scanner sc=new Scanner (system.in);
String Str=sc.next ();//reads the next input, returns a string
SYSTEM.OUT.PRINTLN ("Input content =" +str);
System.out.println ("Please enter the day of the Week (0-6):");
int Week=sc.nextint ();
Switch (week)
{
Case 0://cannot appear alone
System.out.println ("Sunday");
break;//interrupt, cannot be used alone
Case 1:
System.out.println ("Monday");
Break
Case 2:
System.out.println ("Tuesday");
Break
Case 3:
System.out.println ("Wednesday");
Break
Case 4:
System.out.println ("Thursday");
Break
Case 5:
System.out.println ("Friday");
Break
Case 6:
System.out.println ("Saturday");
Break
Default
System.out.println ("Please enter 0-6");
}
System.out.print ("Please enter Age:");
int Age=sc.nextint ();//Read and convert int type
System.out.println ("Age of input is:" +STR);
if (age<18)
{
System.out.println ("Too Young");
}else
{
System.out.println ("Welcome landing");
}
Sc.close ();
}
}
Java, console input and output, switch equivalence comparison