Question: Java 1. Programi prompts the user for an integer and displays the list of months that have the number of total days e.g. if the
1. Programi prompts the user for an integer and displays the list of months that have the number of total days e.g. if the user enters 30, the system displays APRIL, JUNE, SEPTEMBER, NOVEMBER If the user enters a valid positive number that is not a month total, display a message e.g. There are no months with 32 total days. Write an enum named Month that includes the months of the year: January,..., December Each month has a field, days, which is initialized to the number of days in the month (ignore the concept of leap year - February will have 28 days). Complete Programi by writing a method named getMonthlist that determines which months have the number of days that is passed to it. - Check first to see if the argument is a valid positive integer: throw an IllegalArgumentException if it is negative Use StringBuilder to create this string of comma-separated months, or a message if there are no months with the given value. - Make no changes to the main method. // Add enum here import java.util.Scanner; import java.lang.IllegalArgumentException; public class Programl public static void main(String[] args) { Scanner kb = new Scanner (System.in); System.out.println("Enter the number of days: "); int input - kb.nextInt(); String result = getMonths (input); System.out.println (result); // Add method here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
