forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeather.java
More file actions
executable file
·43 lines (41 loc) · 1.51 KB
/
Weather.java
File metadata and controls
executable file
·43 lines (41 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* */ package ch08;
/* */
/* */ import java.util.Scanner;
/* */
/* */ public class Weather {
/* */ public static void main(String[] args) {
/* 7 */ int NUMBER_OF_DAYS = 10;
/* 8 */ int NUMBER_OF_HOURS = 24;
/* 9 */ double[][][] data = new double[10][24][2];
/* */
/* */
/* 12 */ Scanner input = new Scanner(System.in);
/* */
/* 14 */ for (int k = 0; k < 240; k++) {
/* 15 */ int day = input.nextInt();
/* 16 */ int hour = input.nextInt();
/* 17 */ double temperature = input.nextDouble();
/* 18 */ double humidity = input.nextDouble();
/* 19 */ data[day - 1][hour - 1][0] = temperature;
/* 20 */ data[day - 1][hour - 1][1] = humidity;
/* */ }
/* */
/* */
/* 24 */ for (int i = 0; i < 10; i++) {
/* 25 */ double dailyTemperatureTotal = 0.0D, dailyHumidityTotal = 0.0D;
/* 26 */ for (int j = 0; j < 24; j++) {
/* 27 */ dailyTemperatureTotal += data[i][j][0];
/* 28 */ dailyHumidityTotal += data[i][j][1];
/* */ }
/* */
/* */
/* 32 */ System.out.println("Day " + i + "'s average temperature is " + (dailyTemperatureTotal / 24.0D));
/* */
/* 34 */ System.out.println("Day " + i + "'s average humidity is " + (dailyHumidityTotal / 24.0D));
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch08/Weather.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/