Skip to content

Commit 53d082f

Browse files
Test Average
1 parent 6bea985 commit 53d082f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Write a program that asks the user to enter three test scores.
3+
The program should display each test score, as well as the average of the scores.
4+
*/
5+
6+
package com.challenges;
7+
8+
import java.util.Scanner;
9+
10+
public class TestAverage {
11+
public static void main(String [] args) {
12+
13+
// Declare Variables
14+
15+
double firstScore;
16+
double secondScore;
17+
double thirdScore;
18+
double avg;
19+
20+
Scanner scanner = new Scanner(System.in);
21+
22+
System.out.println("Please enter the first score: ");
23+
firstScore = scanner.nextDouble();
24+
25+
System.out.println("Please enter the second score: ");
26+
secondScore = scanner.nextDouble();
27+
28+
System.out.println("Please enter the third score: ");
29+
thirdScore = scanner.nextDouble();
30+
31+
avg = (firstScore + secondScore + thirdScore) / 3;
32+
33+
System.out.println("The average of " + firstScore + ", " + secondScore + ", " + thirdScore + " = " + avg);
34+
}
35+
}

0 commit comments

Comments
 (0)