Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a. Create one or more arrays to hold the names of the months and the number of d

ID: 3626681 • Letter: A

Question

a. Create one or more arrays to hold the names of the months and the number of days in each month. Assume that February always has 28 days.

b. Display the contents of the array(s).

c. Ask the user for a number to represent the month: 1 = Jan, 2 = Feb, etc. Search for the corresponding month and display the name of the month and the number of days. If the number is not found, display an error message.

d. Ask the user for the name of a month. Search for the corresponding month and display the number of the month and the number of days. If the month is not found, display an error message.

Explanation / Answer

i don`t know much about java but i think for c a switch statement will do the job an example import java.io.*; public class SwitchExample{ public static void main(String[] args) throws Exception{ int x, y; BufferedReader object = new BufferedReader (new InputStreamReader(System.in)); System.out.println("Enter two numbers for operation:"); try{ x = Integer.parseInt(object.readLine()); y = Integer.parseInt(object.readLine()); System.out.println("1. Add"); System.out.println("2. Subtract"); System.out.println("3. Multiply"); System.out.println("4. Divide"); System.out.println("enter your choice:"); int a= Integer.parseInt(object.readLine()); switch (a){ case 1: System.out.println("Enter the number one=" + (x+y)); break; case 2: System.out.println("Enter the number two=" + (x-y)); break; case 3: System.out.println("Enetr the number three="+ (x*y)); break; case 4: System.out.println("Enter the number four="+ (x/y)); break; default: System.out.println("Invalid Entry!"); } } catch(NumberFormatException ne){ System.out.println(ne.getMessage() + " is not a numeric value."); System.exit(0); } } } ---------------- and for d i think this will give u an idea how to search through the array public class MainClass { public static void main(String args[]) { int nums[] = { 6, 8, 3, 7, 5, 6, 1, 4 }; int val = 5; boolean found = false; for (int x : nums) { if (x == val) { found = true; break; } } if (found) System.out.println("Value found!"); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote