1 PackageCom.xunhuan;2 3 ImportJava.util.Scanner;4 5 Public classZUOYE04 {6 7 Public Static voidMain (string[] args) {8 9Scanner meng00 =NewScanner (system.in);Ten intnum=0;//defining an int variable OneString day= "";//defining the day variable A - //Do ... wuhile cycle - Do{ theSystem.out.println ("Please enter a number of 0-7:");//input -num =meng00.nextint (); - //If Judgment - if(num>7| | Num<0) { +SYSTEM.OUT.PRINTLN ("Wrong input!");//input is greater than 7 or less than 0 input error - Break; +}Else if(num==0){ ASystem.out.println ("End");//Input 0 End at Break; - -}Else{ - //If judge otherwise else - Switch(num) { - Case1: inDay= "Today is Mon"; - to Break; + Case2: -Day= "Today is Tue"; the * Break; $ Case3: Panax NotoginsengDay= "Today is Wed"; - the Break; + Case4: ADay= "Today is Thu"; the + Break; - Case5: $Day= "Today is Fri"; $ Break; - Case6: -Day= "Today is the SAT"; the Break; - Case7: WuyiDay= "Today is Sun"; the Break; - Wu } - System.out.println (day); About } $ -} while(num!=0);//not equal to 0 - - A } + the}
Java Fundamentals (fifth post-course assignments) 04