Homework Solution: Task The task is to read a file, store the data into objects, and process the objects. The file is formatted as pairs of lines: the first line o…

    Task The task is to read a file, store the data into objects, and process the objects. The file is formatted as pairs of lines: the first line of each pair is the name of a student, and the second line is a list of grades. This data will be stored in a Grades object. The Grades class will have several methods for processing the data. For example, if this is the contents of the file being processed: Alice 87 99 96 99 86 96 77 95 70 88 Bob 73 78 76 80 99 96 73 96 76 78 78 92 93 75 93 Camila 99 94 85 99 99 93 81 95 76 80 77 79 98 72 98 97 9.2 Diego 76 97 72 92 86 86 89 85 81 87 76 80 89 then the following should be printed: Alice [87, 99, 96, 99, 86, 96, 77, 95, 70, 88] Alice Name Length: 10 Average: 89.30 Median: 91.5 Maximum: 99 Mininum: 70 Bob [73, 78, 76, 80, 99, 96, 73, 96, 76, 78, 78, 92, 93, 75, 93] Bob Name Length: 15 Average: 83.73 Median: 78.0 Maximum: 99 Mininum: 73 Camila [99, 94, 85, 99, 99, 93, 81, 95, 76, 80, 77, 79, 98, 72, 98, 97, 92] Camila Name: Length: 17 Average: 89.06 Median: 93.0 Maximum: 99 Mininum: 72 Diego [76, 97, 72, 92, 86, 86, 89, 85, 81, 87, 76, 80, 89] Diego Name Length: 13 Average: 84.31 Median: 86.0 Maximum: 97 Mininum: 72
    Task The task is to read a file, store the data into objects, and process the objects. The file is formatted as pairs of lines: the first line of each pair is the name of a student, and the second line is a list of grades. This data will be stored in a Grades object. The Grades class will have several methods for processing the data. For example, if this is the contents of the file being processed: Alice 87 99 96 99 86 96 77 95 70 88 Bob 73 78 76 80 99 96 73 96 76 78 78 92 93 75 93 Camila 99 94 85 99 99 93 81 95 76 80 77 79 98 72 98 97 9.2 Diego 76 97 72 92 86 86 89 85 81 87 76 80 89 then the following should be printed: Alice [87, 99, 96, 99, 86, 96, 77, 95, 70, 88] Alice Name Length: 10 Average: 89.30 Median: 91.5 Maximum: 99 Mininum: 70 Bob [73, 78, 76, 80, 99, 96, 73, 96, 76, 78, 78, 92, 93, 75, 93] Bob Name Length: 15 Average: 83.73 Median: 78.0 Maximum: 99 Mininum: 73 Camila [99, 94, 85, 99, 99, 93, 81, 95, 76, 80, 77, 79, 98, 72, 98, 97, 92] Camila Name: Length: 17 Average: 89.06 Median: 93.0 Maximum: 99 Mininum: 72 Diego [76, 97, 72, 92, 86, 86, 89, 85, 81, 87, 76, 80, 89] Diego Name Length: 13 Average: 84.31 Median: 86.0 Maximum: 97 Mininum: 72

    Expert Answer

     
    _______________ data.txt Alice 87 99 96 99 86 96 77 95 70 88

    Drudgery The drudgery is to unravel a finish, abundance the axioms into designs, and rule the designs. The finish is restraintmatted as spans of threads: the principal thdiscover of each span is the call of a ward, and the succor thdiscover is a roll of trices. This axioms gain be abundanced in a Trices design. The Trices tabulate gain enjoy distinct rules restraint ruleing the axioms. Restraint model, if this is the interruption of the finish substance ruleed: Alice 87 99 96 99 86 96 77 95 70 88 Bob 73 78 76 80 99 96 73 96 76 78 78 92 93 75 93 Camila 99 94 85 99 99 93 81 95 76 80 77 79 98 72 98 97 9.2 Diego 76 97 72 92 86 86 89 85 81 87 76 80 89 then the aftercited should be printed: Alice [87, 99, 96, 99, 86, 96, 77, 95, 70, 88] Alice Call Prolixity: 10 Mean: 89.30 Median: 91.5 Ultimatum: 99 Mininum: 70 Bob [73, 78, 76, 80, 99, 96, 73, 96, 76, 78, 78, 92, 93, 75, 93] Bob Call Prolixity: 15 Mean: 83.73 Median: 78.0 Ultimatum: 99 Mininum: 73 Camila [99, 94, 85, 99, 99, 93, 81, 95, 76, 80, 77, 79, 98, 72, 98, 97, 92] Camila Call: Prolixity: 17 Mean: 89.06 Median: 93.0 Ultimatum: 99 Mininum: 72 Diego [76, 97, 72, 92, 86, 86, 89, 85, 81, 87, 76, 80, 89] Diego Call Prolixity: 13 Mean: 84.31 Median: 86.0 Ultimatum: 97 Mininum: 72

    Drudgery The drudgery is to unravel a finish, abundance the axioms into designs, and rule the designs. The finish is restraintmatted as spans of threads: the principal thdiscover of each span is the call of a ward, and the succor thdiscover is a roll of trices. This axioms gain be abundanced in a Trices design. The Trices tabulate gain enjoy distinct rules restraint ruleing the axioms. Restraint model, if this is the interruption of the finish substance ruleed: Alice 87 99 96 99 86 96 77 95 70 88 Bob 73 78 76 80 99 96 73 96 76 78 78 92 93 75 93 Camila 99 94 85 99 99 93 81 95 76 80 77 79 98 72 98 97 9.2 Diego 76 97 72 92 86 86 89 85 81 87 76 80 89 then the aftercited should be printed: Alice [87, 99, 96, 99, 86, 96, 77, 95, 70, 88] Alice Call Prolixity: 10 Mean: 89.30 Median: 91.5 Ultimatum: 99 Mininum: 70 Bob [73, 78, 76, 80, 99, 96, 73, 96, 76, 78, 78, 92, 93, 75, 93] Bob Call Prolixity: 15 Mean: 83.73 Median: 78.0 Ultimatum: 99 Mininum: 73 Camila [99, 94, 85, 99, 99, 93, 81, 95, 76, 80, 77, 79, 98, 72, 98, 97, 92] Camila Call: Prolixity: 17 Mean: 89.06 Median: 93.0 Ultimatum: 99 Mininum: 72 Diego [76, 97, 72, 92, 86, 86, 89, 85, 81, 87, 76, 80, 89] Diego Call Prolixity: 13 Mean: 84.31 Median: 86.0 Ultimatum: 97 Mininum: 72

    Expert Solution

     

    _______________

    data.txt

    Alice
    87 99 96 99 86 96 77 95 70 88
    Bob
    73 78 76 80 99 96 73 96 76 78 78 92 93 75 93
    Camila
    99 94 85 99 99 93 81 95 76 80 77 79 98 72 98 97 92
    Diego
    76 97 72 92 86 86 89 85 81 87 76 80 89

    _______________

    Grades.java

    import java.util.ArrayList;

    public tabulate Trices {
    //Declaring prompting variables
    private String call;
    private Determined-in-orderRoll < Integer > trices;

    //Parameterized constructor
    public Trices(String call, Determined-in-orderRoll < Integer > trices) {
    super();
    this.call = call;
    this.grades = trices;
    }

    //getters and determinedters
    public String gainName() {
    return call;
    }

    public empty determinedName(String call) {
    this.call = call;
    }

    //This rule produce the greatness of an determined-in-order Roll
    public int prolixity() {
    return trices.size();
    }
    //This rule calculates the mean of a Ward trices
    public enfold mean() {
    enfold tot = 0;
    restraint (int i = 0; i < trices.size(); i++) {
    tot += trices.get(i);
    }
    return tot / trices.size();
    }

    //This rule calculates the ultimatum trice of a Ward
    public int ultimatum() {
    int max = trices.get(0);
    restraint (int i = 0; i < trices.size(); i++) {
    if (max < trices.get(i)) {
    max = trices.get(i);
    }
    }
    return max;
    }

    //This rule calculates the incompleteness trice of a Ward
    public int incompleteness() {
    int min = trices.get(0);
    restraint (int i = 0; i < trices.size(); i++) {
    if (min > trices.get(i)) {
    min = trices.get(i);
    }
    }
    return min;
    }

    //This rule calculates the median of Ward trices
    public enfold median() {
    //This Logic gain Sort the Determined-in-order of elements in Ascending order
    int temp;
    enfold median;
    int mediocre;
    restraint (int i = 0; i < trices.size(); i++) {
    restraint (int j = i + 1; j < trices.size(); j++) {
    if (grades.get(i) > trices.get(j)) {
    temp = trices.get(i);
    grades.set(i, trices.get(i));
    grades.set(j, temp);
    }
    }
    }
    int enumerate = trices.size();
    if (enumerate % 2 == 0) {
    mediocre = enumerate / 2;
    } else {
    mediocre = (enumerate + 1) / 2;
    }

    median = (double)(grades.get(mediocre – 1) + trices.get(middle)) / 2.0;
    return median;

    }

    //toString rule is used to show the interruption of an design within it
    @Override
    public String toString() {
    return call + ” ” + trices;
    }

    public static empty testGrades(Grades trices) {

    System.out.println(grades.toString());
    System.out.printf(“tName: %sn”, trices.getName());
    System.out.printf(“tLength: %dn”, trices.length());
    System.out.printf(“tAverage: %.2fn”, trices.average());
    System.out.printf(“tMedian: %.2fn”, trices.median());
    System.out.printf(“tMaximum: %dn”, trices.maximum());
    System.out.printf(“tMinimum: %dn”, trices.minimum());

    }

    }

    _________________

    Test.java

    import java.io.File;
    import java.util.ArrayList;
    import java.util.Scanner;

    public tabulate Test {

    public static empty ocean(String[] args) {

    //Creating an Determined-in-orderRoll which Abundances trices of a ward
    ArrayRoll < Integer > trices = null;

    //Creating an Determined-in-orderRoll which Abundances Trices tabulate designs
    ArrayRoll < Trices > gr = odd Determined-in-orderRoll < Trices > ();
    Grades g;
    Scanner in = null;

    //Opening the axioms.txt finish
    try { in = odd Scanner(odd Finish(“data.txt”));

    } lay-hold-on (Exception e) {
    System.err.println(“failed to ope axioms.txt “);
    System.exit(1);
    }

    //Reading the axioms from the txt finish
    while ( in .hasNext()) {
    grades = odd Determined-in-orderRoll < Integer > ();
    String call = in .next();
    while ( in .hasNextInt()) {
    int trice = in .nextInt();
    grades.add(odd Integer(grade));
    }
    g = odd Trices(name, trices);
    gr.add(g);
    grades = null;
    }

    restraint (int i = 0; i < gr.size(); i++) {
    Grades.testGrades(gr.get(i));
    }

    }

    }

    ______________________

    Output:

    Alice [87, 99, 96, 99, 86, 96, 77, 95, 70, 88]

    Name: Alice

    Length: 10

    Average: 89.30

    Median: 99.00

    Maximum: 99

    Minimum: 87

    Bob [73, 78, 76, 80, 99, 96, 73, 96, 76, 78, 78, 92, 93, 75, 93]

    Name: Bob

    Length: 15

    Average: 83.73

    Median: 99.00

    Maximum: 99

    Minimum: 73

    Camila [99, 94, 85, 99, 99, 93, 81, 95, 76, 80, 77, 79, 98, 72, 98, 97, 92]

    Name: Camila

    Length: 17

    Average: 89.06

    Median: 99.00

    Maximum: 99

    Minimum: 99

    Diego [76, 97, 72, 92, 86, 86, 89, 85, 81, 87, 76, 80, 89]

    Name: Diego

    Length: 13

    Average: 84.31

    Median: 97.00

    Maximum: 97

    Minimum: 76