-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHw1prob10.java
More file actions
28 lines (24 loc) · 1.07 KB
/
Hw1prob10.java
File metadata and controls
28 lines (24 loc) · 1.07 KB
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
//CSC110
//Professor Scheiman
//Jairo Molina
//Spring 2018
package hw1prob10;//DELETE THIS line if the program is not working.
import java.util.Scanner;//imports the java utility Scanner
public class Hw1prob10 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);//classifies Scanner utility under the variable scan.
int scores []=new int[4];//creates an array named scores
int total = 0; //creates a variable type integer
for(int x = 1;x<=3;x++ ){//creates a for loop from 1 - 3
System.out.println("Enter score for test "+ x);//displays string
scores[x] = scan.nextInt();//inputs x array 3 times
total += scores[x];//adds each array to the total
}
double total1 = total/3;//obtains average
System.out.println("");//creates empty line
for(int x = 1; x<=3;x++){//creates a for loop range 1-3
System.out.println("Test "+x+":"+scores[x]);//displays string
}
System.out.println("The average is: "+total1+"%");//displays string
}
}