Skip to content

Commit 6acd035

Browse files
Add files via upload
1 parent 20b0b59 commit 6acd035

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

Diff for: Input Output and Exception Handling/Program 1/Total.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@ public static void main(String[] args) throws FileNotFoundException
3030
// Read the input and write the output
3131

3232
double total = 0;
33+
int count = 0;
3334

3435
while (in.hasNextDouble())
3536
{
3637
double value = in.nextDouble();
37-
System.out.println(value);
38-
out.printf("%15.2f\n", value);
38+
double value1 = in.nextDouble();
39+
System.out.println(value+" "+value1);
40+
out.printf("\n%8.2f %8.2f\n", value,value1);
3941
total = total + value;
42+
count = count + 1;
4043
}
4144

42-
out.printf("Total: %8.2f\n", total);
45+
out.printf("\n Total: %8.2f\n", total);
46+
out.printf("\n Average: %8.2f\n",total/count);
47+
4348

4449
in.close();
4550
out.close();
+14-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
32.00
2-
54.00
3-
67.50
4-
29.00
5-
35.00
6-
80.00
7-
115.00
8-
44.50
9-
100.00
10-
65.00
11-
Total: 622.00
1+
2+
32.00 54.00
3+
4+
67.50 29.00
5+
6+
35.00 80.00
7+
8+
115.00 44.50
9+
10+
100.00 65.00
11+
12+
Total: 349.50
13+
14+
Average: 69.90

0 commit comments

Comments
 (0)