-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam.java
More file actions
45 lines (32 loc) · 1.07 KB
/
Exam.java
File metadata and controls
45 lines (32 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Program Name: Exam
//Author: Joshua Decker
//Class: CSC110
//Date Written: 1/31/2022
//Brief Description: Returns average of three exam scores that are input by user (manually entered into code per instructions obtained).
package ch2;
import java.util.Scanner;
public class Exam {
public static void main(String[] args)
{
// declare variables
int exam1, exam2, exam3;
double average;
int numberOfExams = 3;
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
System.out.print("Enter the first exam score: ");
exam1 = scan.nextInt();
System.out.print("Enter the second exam score: ");
exam2 = scan.nextInt();
System.out.print("Enter the third exam score: ");
exam3 = scan.nextInt();
average = (double)(exam1 + exam2 + exam3) / numberOfExams;
System.out.print("The average exam score is: " + average);
}
}
/* My output
* Enter the first exam score: 90
* Enter the second exam score: 91
* Enter the third exam score: 100
* The average exam score is: 93.66666666666667
*/