Question

In: Computer Science

Write a java program that takes 5 students final test scores from console when prompting. Store...

Write a java program that takes 5 students final test scores from console when prompting. Store these scores in an array. Iterate thru the array of student scores to find –

  • Highest score entered

  • Lowest score entered

  • Average of all the 5 scores

  • Total of all the scores

Print these values to the console (screen).

Solutions

Expert Solution

Code:
import java.util.Scanner;
public class Main
{
   public static void main(String[] args) {
   Scanner scan = new Scanner(System.in);
   int marks[];
marks = new int[5];
//taking input from users
for(int i=0;i<5;i++) {
       System.out.print("Enter Student " + (i+1) + " score: ");
       marks[i] = scan.nextInt();
}
//Initiating high, low to marks 0th index and sum, average to 0
int high = marks[0];
int low = marks[0];
int sum = 0;
int average = 0;
//calculating highest, lowest and sum of scores
for(int i=0;i<5;i++) {
if (marks[i] > high)
high = marks[i];
if (marks[i] < low)
low = marks[i];
sum = sum + marks[i];
}
average = sum/5;
//displaying result
System.out.println("\nThe highest score is: " + high);
System.out.println("The lowest score is: " + low);
System.out.println("The sum of all scores is: " + sum);
System.out.println("The average of all score is: " + average);
   }
}
Code Photo:
Output:


Related Solutions

(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and...
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and stores them in a 1D array of size 15. Next, prompt the user for a number to search for in the array (target). Then, print the array. Next, search the array using a linear search – printing out each of the indices (or “indexes”) that are being examined until the algorithm either finds the target or doesn’t. Then, do the same thing for a...
In JAVA • Write a program that calculates the average of a group of test scores,...
In JAVA • Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following methods: • int getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This method should be called by main once for each of the five scores to be entered. • void calcAverage() should calculate and display the average of the...
In java, Write a program that reads a data file containing final exam scores for a...
In java, Write a program that reads a data file containing final exam scores for a class and determines the number of passing scores (those greater than 60) and the number of failing scores (those less than 60). The average score as well as the range of scores should also be determined. The program should request the name of the data file from the end user. The file may contain any number of scores. Using a loop, read and process...
Write JAVA program that finds 3 students with the best scores. The program asks users for...
Write JAVA program that finds 3 students with the best scores. The program asks users for scores of 5 students. The program prints the first, second, third place students and scores. You can assume that there is no two students with the same score. <EXAMPLE> enter the score of each student score of student 1: 50 score of student 2: 70 score of student 3: 30 score of student 4: 90 score of student 5: 40 1st place is student...
IN JAVA: Write a simple program that takes 5 inputs from the user and save them...
IN JAVA: Write a simple program that takes 5 inputs from the user and save them into a Text File. The inputs are Student Name, Student Address and student Date of Birth. Also write a simple program that reads and display the input from the first program text file.
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT