Westonci.ca is the premier destination for reliable answers to your questions, brought to you by a community of experts. Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

JAVA
Write a method that takes a parameter for the number of a month and prints the month's name. You may assume that the actual parameter value
passed to the method is always between 1 and 12 inclusive.
This method must be called monthName() and it must have an integer parameter.
Calling monthName(8) should print August to the screen.
You can call your method in the program's main method so you can test whether it works, but you must remove or comment out the main method
before checking your code for a score

Sagot :

public class MyClass {

   public static String monthName(int num){

       String arr[] = {"January", "February", "March", "April", "May", "June", "July","August", "September", "October", "November", "December"};

       return arr[num-1];

   }

   public static void main(String args[]) {

     System.out.println(monthName(8));

   }

}

I hope this helps.

Methods are blocks of named statements that can be called from other place in the program

The method in java, where comments are used to explain each line is as follows:

//This defines the method

public static void monthName(int month){

//This initializes the array of months

String months[] = {"January", "February", "March", "April", "May", "June", "July","August", "September", "October", "November", "December"};

//This prints the month name

System.out.print(months[month-1]);     }

Read more about similar programs at:

https://brainly.com/question/22589115

Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.