QuestionQuestion

Create a program Statistics.java based on the following.

A textfile, students.dat, contains data about the performance of students in a test. Each line of data (except the last line) contains a student’s name in capital letters (one word) followed by four test scores. The number of lines of data is unknown beforehand. Each item of data is separated by one or more spaces. The first score after a student’s name represents his mark in Spanish, the second score after his name represents his score in Mathematics, the third represents his score in French and the fourth his score in English. Scores are integer values in the range 0 to 100 inclusive. The last line of the textfile contains one value only – the word ENDDATA, which functions as a sentinel to signal the end of the data.

Write a Java program to read and process each line of the textfile and print the following information (for each line except the last):

•    The number of students in the class
•    The name and average score for each student
•    The highest student average in the class (ignore the possibility of a tie)
•    The name of the student who attained the highest average (ignore the possibility of a tie)
•    The highest mark for each subject

No data validation is necessary.

Sample Data

MARY 50 60 70 80
SHELLY 34 56 90 100
JOHN 32 54 66 88
ALFRED 21 100 88 75
ENDDATA

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Statistics {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
         String name;
         int [] scores = new int[4];
         ArrayList<Student> students = new ArrayList<>();
         
       try {
            Scanner file = new Scanner(new File("students.dat"));
            while (file.hasNext()) {
                name = file.next();
                if (name.equals("ENDDATA")) {
                   break;...
$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats