-2

When running program I have no output to my console window,

Tried selecting different console windows, closing and reopening the window, closing other open code

package Codecademy;

public class Continents {
public static void main(String[] args) {
//This will show a continent and the largest city
    int contient = 4;
    String contientString;

    switch (contient) {
    case 1:
        contientString = "North America: Mexico city Mexico";
        break;
    case 2:
         contientString = "South America: Sao Paulo, Brazil";
break;
case 3:
contientString = "Europe: Moscow, Russia";
break;
case 4:
contientString = "Africa: Lagos, Nigeria";
break;
case 5:
contientString = "Asia: Shanghai, China";
break;
case 6:
contientString = "Australia: Sydney, Australia";
break;
case 7:
contientString = "Antarctica: McMurdo Station, US";
break;
default:
contientString = "Invalid Selection";
break;

}
}
}

South America: Sao Paulo, Brazil (Should be the correct output.)

5
  • What code are you talking about? Commented Jul 9, 2019 at 9:24
  • something like system.otut.println("the correct case")? Commented Jul 9, 2019 at 9:24
  • Show your code... Commented Jul 9, 2019 at 9:25
  • @DevilsHnd the assignment is to write a code that selects a case from the the switch statement. Commented Jul 9, 2019 at 9:27
  • If you want South America: Sao Paulo, Brazil to be the output then contient needs to equal 2: int contient = 2;. Commented Jul 9, 2019 at 9:43

1 Answer 1

0

Then it should be something like this:

int contient = 4;
String contientString;

switch (contient) {
    case 1:
        contientString = "North America: Mexico city Mexico";
        break;
    case 2:
        contientString = "Some 2nd Continent: Some 2d City Some2ndCountry";
        break;
    case 3:
        contientString = "Some 3rd Continent: Some 3rd City Some3rdCountry";
        break;
    case 4:
        contientString = "Some 4th Continent: Some 4th City Some4thCountry";
        break;
    default:
        contientString = "Don't Know What Continent: UNKNOWN";
}

System.out.println(contientString);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.