Write a program to print week days using switch statement

Write a program to print week days using switch statement
class test
{
public static void main(String[] args)
{
int week = 3;
switch (week)
{
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;
case 7:System.out.println(“sunday”);
break;
default:System.out.println(“Invalid week”);
}
}
}

Output:
Wednesday

Leave a Reply

Your email address will not be published. Required fields are marked *