⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weatherfan.java

📁 Java2入门经典第四章源码
💻 JAVA
字号:
public class WeatherFan
{
   public static void main(String[] args)
   {
      float[][] temperature = new float[10][365]; // Temperature array

      // Generate temperatures
      for(int i = 0; i < temperature.length; i++)
         for(int j = 0; j < temperature[i].length; j++)
            temperature[i][j] = (float)(45.0*Math.random() - 10.0);

      // Calculate the average per location
      for(int i = 0; i < temperature.length; i++)
      {
         float average = 0.0f;     // Place to store the average

         for(int j = 0; j < temperature[0].length; j++)
            average += temperature[i][j];

         // Output the average temperature for the current location
         System.out.println("Average temperature at location "
                + (i+1) + " = " + average/(float)temperature[i].length);
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -