In: Computer Science
import java.util.Scanner;
public class MonthsOnAndAfter {
// You will need to write a method that makes this
// code compile and produce the correct output.
// YOU MUST USE switch!
// As a hint, you should not have to use the name of each
// month more than once.
// TODO - write your code below this comment.
// DO NOT MODIFY main!
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter month (0-11): ");
int month = input.nextInt();
printMonthsOnAndAfter(month);
}
}
import java.util.Scanner;
public class MonthsOnAndAfter {
// You will need to write a method that makes this
// code compile and produce the correct output.
// YOU MUST USE switch!
// As a hint, you should not have to use the name of each
// month more than once.
public static void printMonthsOnAndAfter(int num){
String result = "";
switch (num){
case 1:
result = "January";
break;
case 2:
result = "February";
break;
case 3:
result = "March";
break;
case 4:
result = "April";
break;
case 5:
result = "May";
break;
case 6:
result = "June";
break;
case 7:
result = "July";
break;
case 8:
result = "August";
break;
case 9:
result = "September";
break;
case 10:
result = "October";
break;
case 11:
result = "November";
break;
case 12:
result = "December";
break;
}
System.out.println(result);
}
// DO NOT MODIFY main!
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter month (0-11): ");
int month = input.nextInt();
printMonthsOnAndAfter(month);
}
}

