Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My Code is still thowing errors please help 1. error: '(' expected public static void String monthName(int month) { 2. illegal start of type switch

My Code is still thowing errors please help

1.

error: '(' expected public static void String monthName(int month) {

2. illegal start of type switch (month) { ^

3. expected switch (month) { ^

import java.text.MessageFormat;

import java.util.Scanner;

public class Assignment3 {

/**

* use a switch statement for this function (no ifs allowed)

* 1=January, 2=February ... 12=December (notice they start with uppercase)

* return "Invalid Month" if not between 1 and 12.

* @return

*/

static String theMonth[] = {

"",

"January",

"February",

"March",

"April",

"May",

"June",

"July",

"August",

"September",

"October",

"November",

"December"

};

public static void main(String[] args){

int month = 8;

Scanner sc = new Scanner(System.in);

System.out.print("Enter a Number :");

month = sc.nextInt();

System.out.println(monthName);

}

public static void String monthName(int month) {

String theMonth;

}

switch (month) {

{

int theMonth = monthName.nextInt(1);

String answer = "Invalid Month";

switch (month) {

case 1:

answer = theMonth[1];

break;

case 2:

answer = theMonth[2];

break;

case 3:

answer = theMonth[3];

break;

case 4:

answer = theMonth[4];

break;

case 5:

answer = theMonth[5];

break;

case 6:

answer = theMonth[6];

break;

case 7:

answer = theMonth[7];

break;

case 8:

answer = theMonth[8];

break;

case 9:

answer = theMonth[9];

break;

case 10:

answer = theMonth[10];

break;

case 11:

answer = theMonth[11];

break;

case 12:

answer = theMonth[12];

break;

default:

answer = "Invalid Month";

}

return answer;

}

}

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What do you understand by MBO?

Answered: 1 week ago

Question

What is meant by planning or define planning?

Answered: 1 week ago

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

a. How will the leader be selected?

Answered: 1 week ago