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.
Cet exercice fait partie du cours
Intermediate Java
Instructions
- Use the correct keyword to make it a
case
to 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.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
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");
}
}
}