5) Write a program to print the days in a week if 0=Sunday and 1=Monday and so on till Saturday by using switch-case.        
        1
                    
                            
                                        2012-03-06T10:11:09-0500
                    
                                                    
                                Create the file "DayOfWeek.java" with the following 
contents:
//////////////////////////////
import 
java.util.Scanner;
public class DayOfWeek
{
  public static void 
main (String[] args) 
  {
    Scanner input = new Scanner( 
System.in);
    int day;
    boolean flag;
   
    
System.out.print("Please enter a day number (0-6): ");
    day = 
input.nextInt();
    
    switch (day) {
case 
0:
System.out.printf("Sunday\n");
break;
case 
1:
System.out.printf("Monday\n");
break;
case 
2:
System.out.printf("Tuesday\n");
break;
case 
3:
System.out.printf("Wednesday\n");
break;
case 
4:
System.out.printf("Thursday\n");
break;
case 
5:
System.out.printf("Friday\n");
break;
case 
6:
System.out.printf("Saturday\n");
break;
default:
System.out.printf("Incorrect 
number!\n");
break;
};
   
}
}
//////////////////////////
Compile it with 
  
javac DayOfWeek.java
and run with
  java DayOfWeek                            
                                                 
                 
                    
        
            
                Need a fast expert's response?
                Submit order
                and get a quick answer at the best price
                for any assignment or question with DETAILED EXPLANATIONS!
             
            
            
         
            
        Learn more about our help with Assignments: 
JavaJSPJSF     
 
                        
Comments