Skip to content

Instantly share code, notes, and snippets.

@farhanpro
Last active December 19, 2018 17:50
Show Gist options
  • Save farhanpro/b7164171413e47e840ed37dd0940beee to your computer and use it in GitHub Desktop.
Save farhanpro/b7164171413e47e840ed37dd0940beee to your computer and use it in GitHub Desktop.
Written a method with the name printDayOfTheWeek that has one parameter of type int and name it day.
package com.company;
public class Main {
public static void main(String[] args) {
DayOfTheWeek(1);
DayOfTheWeek(2);
DayOfTheWeek(3);
DayOfTheWeek(4);
DayOfTheWeek(5);
DayOfTheWeek(6);
DayOfTheWeek(7);
}
public static void DayOfTheWeek(int Day){
switch (Day){
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 input");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment