Question: Can someone walk through this problem with as much explanation as possible. Thank you import java.io.*; import java.util.Scanner; class Lesson_32_Activity_One { public static void monthName(int

Can someone walk through this problem with as much explanation as possible.

Thank you

import java.io.*; import java.util.Scanner; class Lesson_32_Activity_One { public static void monthName(int m) { //Use if statements to check for each month individually. //Alternatively, students may create a String array and use //the variable m to access the month, as in the following commented out code. /* * String [] months = {"January", "February", "March", "April", "May", * "June", "July", "August", "September", "October", * "November", "December"}; * return months[m - 1]; */ if (m == 1) System.out.println("January"); if (m == 2) System.out.println("February"); if (m == 3) System.out.println("March"); if (m ==4) System.out.println("April"); if (m == 5) System.out.println("May"); if (m == 6) System.out.println("June"); if (m == 7) System.out.println("July"); if (m == 8) System.out.println("August"); if (m == 9) System.out.println("September"); if (m == 10) System.out.println("October"); if (m == 11) System.out.println("November"); if (m == 12) System.out.println("December"); } //main method to test the program. This is not required by the code-runner, //but is an important step in writing new methods. public static void main(String [] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a month number:"); int m = scan.nextInt(); System.out.println("monthName(" + m + ") prints:"); monthName(m); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!