Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions