Lab exercise Complete the following exercise in your labsess
Solution
Lab5Soin.java
import java.util.Scanner;
 public class Lab5Soin {
  
    public static void main(String[] args) {
        int monthInt;
        String monthName;
        Scanner scan = new Scanner(System.in);
        System.out.println(\"Enter a month using an integer between (1 and 12): \");
        monthInt = scan.nextInt();
        System.out.println(\"Enter a month using its name: \");
        monthName = scan.next();
        String outputString = \"\";
        switch(monthInt){
        case 1: outputString = monthName.equalsIgnoreCase(\"January\")? \"They match!\": \"They don\'t match!\"; break;
        case 2: outputString = monthName.equalsIgnoreCase(\"February\")? \"They match!\": \"They don\'t match!\"; break;
        case 3: outputString = monthName.equalsIgnoreCase(\"March\")? \"They match!\": \"They don\'t match!\"; break;
        case 4: outputString = monthName.equalsIgnoreCase(\"April\")? \"They match!\": \"They don\'t match!\"; break;
        case 5: outputString = monthName.equalsIgnoreCase(\"May\")? \"They match!\": \"They don\'t match!\"; break;
        case 6: outputString = monthName.equalsIgnoreCase(\"June\")? \"They match!\": \"They don\'t match!\"; break;
        case 7: outputString = monthName.equalsIgnoreCase(\"July\")? \"They match!\": \"They don\'t match!\"; break;
        case 8: outputString = monthName.equalsIgnoreCase(\"August\")? \"They match!\": \"They don\'t match!\"; break;
        case 9: outputString = monthName.equalsIgnoreCase(\"September\")? \"They match!\": \"They don\'t match!\"; break;
        case 10: outputString = monthName.equalsIgnoreCase(\"October\")? \"They match!\": \"They don\'t match!\"; break;
        case 11: outputString = monthName.equalsIgnoreCase(\"November\")? \"They match!\": \"They don\'t match!\"; break;
        case 12: outputString = monthName.equalsIgnoreCase(\"December\")? \"They match!\": \"They don\'t match!\"; break;
        default: outputString = \"Invalid month\";
        }
        System.out.println(outputString);
}
}
Output:
Enter a month using an integer between (1 and 12):
 2
 Enter a month using its name:
 February
 They match!
Enter a month using an integer between (1 and 12):
 6
 Enter a month using its name:
 July
 They don\'t match!


