1. Write a program that calculates the average of 10 test scores. This program l
ID: 3642101 • Letter: 1
Question
1. Write a program that calculates the average of 10 test scores. This program lets the user enters 10 test scores into an array. The program will then calculate and output the average of the ten scores, as well as the lowest score. Your program should use the following functions1.void calcAverage: should calculate and display the average of the ten scores. This function should be called only once by the main function, and should accept the array and the size of the array as parameters.
2. void findLowest: should find and display the lowest value of the ten scores. This function should also be called by the main function, and should accept the array and the size of the array as parameters
Explanation / Answer
import java.util.Scanner; public class Driver { int scores[]; public static void main(String[] args) { Driver d = new Driver(); //create a new instance of the class System.out.println("Enter Scores: "); Scanner scan = new Scanner(System.in); String userInput = scan.nextLine(); String prefilteredInput[] = new String[userInput.length()]; prefilteredInput = userInput.split(" ", userInput.length()); //returns an array of strings of the users input that have been separated by a " " space //userInput.length() means go through the whole userInput String d.scores = new int[prefilteredInput.length]; int scoresSize = d.scores.length; for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.