Advertisement
ralphdc09

itf106.pr.wk02.number06

Jul 30th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package pr.wk02;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.*;
  7.  
  8. public class number06 {
  9.     public static void main(String[] args) throws IOException {
  10.  
  11.         BufferedReader reader;
  12.  
  13.         String strLine;
  14.         List<String> list = new ArrayList<>();
  15.  
  16.         reader =
  17.                 new BufferedReader(
  18.                         new FileReader(
  19.                                 "src/pr/wk02/testdata.txt"));
  20.  
  21.         while ((strLine = reader.readLine()) != null) {
  22.  
  23.             list.add(strLine);
  24.         }
  25.  
  26.         String name = list.get(0);
  27.         int exam1 = Integer.parseInt(list.get(1));
  28.         int exam2 = Integer.parseInt(list.get(2));
  29.         int exam3 = Integer.parseInt(list.get(3));
  30.  
  31.         System.out.println(name);
  32.  
  33.         double average;
  34.         average = (exam1 + exam2 + exam3) / 3;
  35.  
  36.         System.out.printf("Average grade of " + name + " was " + "%1.2f", average);
  37.         System.out.println();
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement