Code Error


#1

No idea why this won't work!

//some country stuff
public class Continents {
	public static void main(String[] args) {
		int continent = 4;
    	Case 1: System.out.println("North America: Mexico City, Mexico");
      break;
      Case 2: System.out.println("South America: Sao Paulo, Brazil");
      break;        
      Case 3: System.out.println("Europe: Moscow, Russia");
      break;        
      Case 4: System.out.println("Africa: Lagos, Nigeria");
      break;        
      Case 5: System.out.println("Asia: Shanghai, China");
      break;        
      Case 6: System.out.println("Australia: Sydney, Australia");
      break;        
      Case 7: System.out.println("Antartica: McMurdo Station, US");
      break;        
      default: System.out.println("Undefined continent!");
      break;
  	}
  }
}

#2

What do you mean by not working?


#3

Your code is very unlikely to be working. You're attempting to use case statements without switch.
Using case requires that you state your variable-to-check in switch()

Wrap the case statements in this: switch(continent) {}

Also, the case statements are completely lower-case. Change Case to case.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.