language: Java (sun-jdk-1.7.0_10)
date: 174 days 21 hours ago
link:
visibility: public
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import java.io.*;
import java.util.*;
import java.awt.*;
 
public class weather {
 
    public static void main(String[] args)
 
        throws FileNotFoundException {
 
                Scanner input = new Scanner(new File("PortlandWeather2011.txt"));
 
                String x = input.nextLine();
                System.out.println(x);
                String y = input.nextLine();
                System.out.println(y);
 
                int count = 0;
                while (input.hasNextLine()) {
 
                        process(input);
                        count++;
 
                }
 
                double[] precip = new double[count];
                double[] snow = new double[count];
                double[] snowDepth = new double[count];
                double[] tempMin = new double[count];
                double[] tempMax = new double[count];
 
                input = new Scanner(new File("PortlandWeather2011.txt"));
 
                x = input.nextLine();
                System.out.println(x);
                y = input.nextLine();
                System.out.println(y);
 
                count = 0;
                while (input.hasNextLine()) {
                        input.next();
                        input.next();
                        precip[count] = input.nextDouble();
                        snow[count] = input.nextDouble();
                        snowDepth[count] = input.nextDouble();
                        tempMax[count] = input.nextDouble();
                        tempMin[count] = input.nextDouble();
                        count++;
                }
                
                System.out.println(arrayAvg(precip));
                System.out.println(arrayAvg(snow));
                System.out.println(arrayAvg(snowDepth));
                System.out.println(arrayAvg(tempMin));
                System.out.println(arrayAvg(tempMax));
        }
 
        public static double arrayAvg(double a[]) {
                int count = 0;
                double sum = 0;
                for (int i = 0; i < a.length; i++) {
                        count++;
                        if (a[i] != 393.7) {
                                sum += a[i];
                                
 
                        }
                        
                }
                return sum/count;
        }
 
        public static void process(Scanner input) {
                while (input.hasNext()) {
                        String station = input.next();
 
                        while (input.hasNextInt()) {
                                String date = input.next();
 
                                while (input.hasNextInt()) {
                                        int precipitation = input.nextInt();
 
                                        while (input.hasNextInt()) {
                                                int snow = input.nextInt();
 
                                                while (input.hasNextInt()) {
                                                        int snowDepth = input.nextInt();
 
                                                        while (input.hasNextInt()) {
                                                                int tempMin = input.nextInt();
 
                                                                while (input.hasNextInt()) {
                                                                        int tempMax = input.nextInt();
 
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }
 
        public static double tempConvert(int n) {
                double celsius = (n / 10.0) * 9 / 5 + 32;
 
                return celsius;
        }
 
        public static double snowConvert(int n) {
                double snowInches = n * 0.03937;
 
                return snowInches;
        }
 
        public static double precipitationConvert(int n) {
                double rainInches = ((n * 0.03937) / 10);
                return rainInches;
        }
 
}
 
Main.java:5: class weather is public, should be declared in a file named weather.java
public class weather {
       ^
1 error