-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExercise.java
More file actions
37 lines (28 loc) · 896 Bytes
/
Copy pathExercise.java
File metadata and controls
37 lines (28 loc) · 896 Bytes
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
package Online_Code_Samples.Week2;
import java.util.Scanner;
public class Exercise {
public static void main(String[] args) {
int[] arrayTotal = new int[4];
int total = 0;
int arrayIndex = 0;
Scanner scanner = new Scanner(System.in);
int count = 1;
do{
System.out.print("Please enter a valid integer: ");
int entered = scanner.nextInt();
total += entered;
if( count % 5 == 0){
arrayTotal[arrayIndex++] = total;
total = 0;
}
count++;
} while ( count <= 20);
scanner.close();
count = 1;
for( int integer: arrayTotal ){
System.out.println("Series " + count++ + " total = " + integer);
total+= integer;
}
System.out.println("Total summation = " + total);
}
}