Question: This is for JAVA My assignment is to write a program, GetInput.java, that uses an integer from the command line argument. This number should have
This is for JAVA
My assignment is to write a program, GetInput.java, that uses an integer from the command line argument. This number should have a value between 1 to 12 (inclusive). Each number represents a month in the year. 1 is for January, 2 is for February and so on. If the number provided does not fall in this range, then the program prints out an error message and terminates. I only have a portion of my code which is below. I do not know how to do the rest. I also have examples of what it should look like in the end. Thanks!


public class GetInput public static void main(String[] args) int month Integer.parseInt(args [0]); String monthString; switch (month) case 1: monthSt ring-"January". break case 2: monthString-"February"; break case 3: monthString "March"; break; case 4:monthString"April"; break; case 5 monthString "May"; break case 6: monthString -"June"; break; case 7 monthString "July"; break; case 8 monthString"August"; System.out.println("This will be executed too!"); case 9: monthString "September"; break; case 1O: monthString "October"; break case 11: monthString "November"; break case 12: monthString "December"; break default: monthString "Invalid month" ;break; System.out.println (monthString); >java GetInput 8 Hello, your month is in the summer season. >jave GetInput 12 Hello, your month is in the winter season >java GetInput 15 Sorry, invalid input. Goodbye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
