Question: Write one This method must be called monthName() and it must have an integer parameter. method that takes a parameter for the number of a

Write one This method must be called monthName() and it must have an integer parameter.

method that takes a parameter for the number of a month and prints the month's name. Assume that the actual parameter value passed to the method is always between 1 and 12 inclusive.

Calling monthName(8) should print August to the screen.

It can call a method in the program's main method so that can be test whether it works, but it must remove or comment out the main method

For this question, I write something like this:

/* Add the method monthName here */

public static void monthName(int month)

{

if(month == 0)

{

System.out.println("That's not within the range 1 -12");

}

public static void main(String[] args)

{

int month = scan.nextInt();

monthName(8);

}

}

But in general, what should I do in order to print all 12 months within a parameter. Can someone help me out this and also write some explanation how it work when it come to writing method correctly?

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!