SHOW:
|
|
- or go back to the newest paste.
1 | import java.io.*; | |
2 | import java.util.*; | |
3 | ||
4 | public class studentScores { | |
5 | ||
6 | String readout; | |
7 | int nameIndex; | |
8 | - | displayHeader(); |
8 | + | |
9 | - | System.out.println(""); |
9 | + | |
10 | ||
11 | ||
12 | - | File f = new File("students.txt"); |
12 | + | BufferedReader br = new BufferedReader(new FileReader(file)); |
13 | - | Scanner sc = new Scanner(f); |
13 | + | String line; |
14 | - | String line = sc.nextLine(); |
14 | + | while ((line = br.readLine()) != null) { |
15 | - | while(sc.hasNext()) { |
15 | + | |
16 | nameIndex = line.indexOf(':'); | |
17 | readout = line.substring(0, nameIndex) + ( | |
18 | - | for (int i = 0; i < line.length(); i++) { |
18 | + | } |
19 | - | if (line.charAt(i) != ':') { |
19 | + | br.close(); |
20 | - | |
20 | + | |
21 | - | System.out.print(line.charAt(i)); |
21 | + | |
22 | - | sc.nextLine(); |
22 | + | |
23 | - | |
23 | + | |
24 | } | |
25 | - | } |
25 | + | |
26 | ||
27 | - | else { |
27 | + | |
28 | - | |
28 | + | |
29 | - | line = sc.nextLine(); |
29 | + | |
30 | - | System.out.println(""); |
30 | + | |
31 | - | } |
31 | + | |
32 | - | } |
32 | + | |
33 | ||
34 | } | |
35 | return sum/a.length; | |
36 | ||
37 | } | |
38 | ||
39 | ||
40 | ||
41 | ||
42 | public static void tester(){ | |
43 | int[] tests ={90,90,80,80}; | |
44 | System.out.print(average(tests)); | |
45 | ||
46 | ||
47 | } | |
48 | ||
49 | public static void displayHeader() { | |
50 | ||
51 | System.out.println("Student Name e1 e2 e3 e4 ave"); | |
52 | System.out.println("---------------------------------------------------------"); | |
53 | ||
54 | } | |
55 | ||
56 | //public static void displayStudent(String name, scores, double average) { | |
57 | //Write in terms of name, scores, and average | |
58 | ||
59 | //} | |
60 | ||
61 | ||
62 | ||
63 | ||
64 | ||
65 | } |