Weather Reporter
You've found a way to retrieve the weather report for your location. You want to have a small program that tells you what item to use in different types of weather.
Diese Übung ist Teil des Kurses
Intermediate Java
Anleitung zur Übung
- Use the correct keyword to make it a
caseto check. - Put in the right constant to print only when it is
"Sunny". - Write the correct keyword down to make sure only one
println()will take effect.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
class WeatherReporter {
public static void main(String[] args) {
String weather = "Sunny";
switch (weather) {
// Use the correct keyword to make it a case to check
____ "Windy":
System.out.println("Take an umbrella");
break;
// Enter the appropriate name to check for sunny
case "____":
System.out.println("Don't forget your sunscreen");
// Write the correct keyword down to make sure the message will be unique
____;
case "Cloudy":
System.out.println("The umbrella might be great");
break;
default:
System.out.println("I don't know what the weather will be like");
}
}
}