-
Notifications
You must be signed in to change notification settings - Fork 1
/
whatever.java
49 lines (42 loc) · 1.26 KB
/
whatever.java
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
import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
public class whatever {
public static void main(String[] args) throws FileNotFoundException {
ArrayList<ArrayList> nums = new ArrayList<>();
File inputFile = new File("in1");
Scanner in = new Scanner(inputFile);
PrintWriter out = new PrintWriter("yeet.txt");
int lineCounter = 0;
while(in.hasNextLine()){
ArrayList<Double> num = new ArrayList<>();
String str;
str = in.nextLine();
String[] strs = str.split("\\s+");
for (int i=0; i<strs.length; i++) {
num.add(Double.parseDouble(strs[i]));
}
nums.add(num);
}
Double[] sums = {0.0, 0.0, 0.0};
System.out.println(nums.toString());
for(int i=0; i<nums.size(); i++) {
for(int j=0; j<nums.get(i).size(); j++){
double ya = (Double)nums.get(i).get(j);
out.printf("%5.1f", ya);
sums[j] += ya;
}
out.print("\n");
}
out.print("Sum: ");
for (int i=0; i<sums.length;i++) {
out.printf("%5.1f",sums[i]);
}
System.out.print(Arrays.toString(sums));
in.close();
out.close();
}
}