Write a java application that uses an integer array to get a series of test scor
ID: 3772546 • Letter: W
Question
Write a java application that uses an integer array to get a series of test scores, compute the average and output the scores in tabular form and the class averages rounded to 2 decimal places.
Class report
Test# Test score
1 92
2 85
3 78
4 90
5 86
6 93
7 88
Class average 87.43
Constants
int MAXSIZE = 25;
Variables int [] testScores; double average; int numberOfTests; int total; Int [] testScores = new int [MAXSIZE];
BEGIN
numberOfTest = -1
do
Increment numberOfTest ++
Display “Please enter test number” + (numberOfTest + 1)
+ “< -1 to exit> ”
Get testScores[numberOfTests]
WHILE testScores[numberOfTests] > 0
Explanation / Answer
import java.io.*;
import java.util.array;
import java.util.Scanner;
public class Result
{
int MAXSIZE=25;
public static void main(String [] args)
{
int testscores[];
double average;
int numTests, total;
int testscores[ ] =new testscores[MAXSIZE];
numTest=-1;
total=0;
Scanner in= new Scanner(System.in);
do
{
numTest++;
System.out.println("Enter Test score of Test"+(numTest+1)+"or -1 to exit ");
testscore[numTest]=in.nextInt();
total= total + testscore[numTest];
}
while (numTest <25);
average = total/numTest; //OR average= total/25;
System.out.println("class average is :"+average);
System.out.print("Test Score");
System.out.println();
for(int i=1;i<=25;i++)
{
System.out.print(i+" "+testscore[i]);
System.out.println();
}
} //end of main
} // end of Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.