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

टेबल की संरचना संशोधित करना

मौसम विज्ञान स्टेशन को अब नए तापमान पूर्वानुमानों के लिए अपनी वेदर डेटा टेबल अपडेट करनी है. वे तुलना के लिए वास्तविक दर्ज तापमान को रखते हुए पूर्वानुमानित तापमान जोड़ना चाहते हैं.

Tablesaw की Table, DoubleColumn, और StringColumn क्लास आपके लिए इम्पोर्ट कर दी गई हैं.

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

Java में डेटा इम्पोर्ट करना

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

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

  • "Temperature" कॉलम का नाम बदलकर "ActualTemp" रखें.
  • टेबल में एक नया "ForecastTemp" कॉलम जोड़ें.
  • टेबल की संरचना प्रिंट करें.
  • पहली तीन पंक्तियाँ प्रिंट करें.

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

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

public class ModifyWeatherTable {
    public static void main(String[] args) {
        StringColumn days = StringColumn.create("Day", 
            "Monday", "Tuesday", "Wednesday");
            
        DoubleColumn temperatures = DoubleColumn.create("Temperature", 
            22.5, 24.0, 23.2);
            
        DoubleColumn precipitation = DoubleColumn.create("Precipitation", 
            0.0, 2.5, 5.2);
            
        Table weatherData = Table.create("WeatherData")
            .addColumns(days, temperatures, precipitation);
        
        // Rename the Temperature column
        weatherData.____("Temperature").____("____");
        
        // Add a new ForecastTemp column
        DoubleColumn forecastTemps = DoubleColumn.create("ForecastTemp", 
            23.0, 25.2, 22.8);
        weatherData = weatherData.____(forecastTemps);
        
        // Print the table structure
        System.out.println(weatherData.____());
        
        // Print the first three rows
        System.out.println(weatherData.____(____));
        
    }
}
कोड संपादित करें और चलाएँ