Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

How does Elon Musk constrain Tesla's options?

Answered: 1 week ago