File tree 2 files changed +22
-14
lines changed
Input Output and Exception Handling/Program 1
2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,21 @@ public static void main(String[] args) throws FileNotFoundException
30
30
// Read the input and write the output
31
31
32
32
double total = 0 ;
33
+ int count = 0 ;
33
34
34
35
while (in .hasNextDouble ())
35
36
{
36
37
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 );
39
41
total = total + value ;
42
+ count = count + 1 ;
40
43
}
41
44
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
+
43
48
44
49
in .close ();
45
50
out .close ();
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments