शुरू करेंमुफ़्त में शुरू करें

Weather Reporter

आपने अपने लोकेशन के लिए मौसम रिपोर्ट लाने का तरीका ढूँढ़ लिया है. आप एक छोटा प्रोग्राम चाहते हैं जो अलग-अलग मौसम में कौन-सी चीज़ इस्तेमाल करनी है, यह बताए.

यह अभ्यास पाठ्यक्रम का हिस्सा है

इंटरमीडिएट Java

पाठ्यक्रम देखें

अभ्यास निर्देश

  • चेक करने के लिए इसे case बनाने हेतु सही कीवर्ड का उपयोग करें.
  • केवल तब प्रिंट करने के लिए सही कॉन्स्टेंट डालें जब यह "Sunny" हो.
  • सुनिश्चित करने के लिए कि केवल एक println() चले, सही कीवर्ड लिखें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

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");
    }
  }
}
कोड संपादित करें और चलाएँ