Bollettino meteo
Hai trovato un modo per recuperare il bollettino meteo della tua posizione. Vuoi creare un piccolo programma che ti dica quale oggetto usare con i diversi tipi di tempo.
Questo esercizio fa parte del corso
Java intermedio
Istruzioni dell'esercizio
- Usa la parola chiave corretta per creare un
caseda verificare. - Inserisci la costante giusta per stampare solo quando è
"Sunny". - Scrivi la parola chiave corretta per assicurarti che venga eseguito un solo
println().
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
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");
}
}
}