Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a JAVA program that reads students’ names followed by their test scores. T

ID: 3842372 • Letter: W

Question

Write a JAVA 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 an instance of class variable of type studentClass, which has four components: StudentFName, studentLName of type string, testScore of type int (testScore is between 0 and 100), and grade of type char. Suppose that the class has 20 students. Use an array of 20 elements of type studentClass.

Your program must contain at least the following methods:

1. A method to read the students’ data into the array
2. A method to assign the relevant grade to each student
3. A method to find the highest test score
4. A method to print the names of the students having the highest test score.
5. Your program must output each student’s name in this form: last name followed by a comma, followed by a space, followed by the first name, the name must be left justified; you 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 as follow:

"C ents and Setti Administrato Student Nane Test Score Grade Donald, Duckey 85 Goof y, Goof 89 Balto Brave 93 Snitn Snow 93 Wonderful, Alice 89 Akthar. Sanina 85 95 Green Sinba Egger, Donald 98 Deer, Brown 86 Jackson Johny 95 Gupta, Greg Happy, Samuel 80 Arora Danny 88 70 June, Sleepy Cheng Any 83 Malik. Shelly 95 Tomek, Chelsea 95 95 Clodfelter, Angela Nields Allison 95 Lance 88 Nornan Highest Test Score 95 tudents having the highest test score Green Simba Jackson Johny Malik Shelly Tonek, Chelsea Clodfelter Angela Nields Allison Press any key to continue,

Explanation / Answer

Data.txt (Save this file under D Drive.Then the path of the file pointing to it is D:\Data.txt)

Duckey Donald 85
Goof Goofy 89
Brave Balto 93
Snow Smitn 93
Alice Wonderful 89
Samina Akthar 85
Simba Green 95
Donald Egger 90
Brown Deer 86
Johny Jackson 95
Greg Gupta 75
Samuel Happy 80
Danny Arora 80
Sleepy June 70
Amy Cheng 83
Shelly Malik 95
Chelsea Tomek 95
Angela Clodfelter 95
Allison Nields 95
Lance Norman 88

__________________

StudentClass.java

public class StudentClass {
  
   //Declaring instance variables
   private String StudentFName;
   private String studentLName;
   private int testScore;
   private char garde;
  
   //parameterized constructor
   public StudentClass(String studentFName, String studentLName, int testScore) {
       super();
       StudentFName = studentFName;
       this.studentLName = studentLName;
       this.testScore = testScore;
   }
  
   //Setters and getters
   public String getStudentFName() {
       return StudentFName;
   }
   public void setStudentFName(String studentFName) {
       StudentFName = studentFName;
   }
   public String getStudentLName() {
       return studentLName;
   }
   public void setStudentLName(String studentLName) {
       this.studentLName = studentLName;
   }
   public int getTestScore() {
       return testScore;
   }
   public void setTestScore(int testScore) {
       this.testScore = testScore;
   }
   public char getGarde() {
       return garde;
   }
   public void setGarde(char garde) {
       this.garde = garde;
   }

}

_____________________

ReadStudentNamestestScores.java

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

public class ReadStudentNamestestScores {

   public static void main(String[] args) throws FileNotFoundException {
       //Declaring variables
       int size=20;
      
       //Creating an Array of type Student Class based on size
StudentClass st[]=new StudentClass[size];
  
//Opening the inout file
Scanner sc=new Scanner(new File("D:\Data.txt"));

//Read the data from the file by calling the method
st=readStudentsData(st,sc);

//Closing the input file
sc.close();

//Finding the grade letter of each student based on his test score.
assignGradeLetter(st);

//Finding the highest score
int highest=findHighestTestScore(st);
System.out.println(" ");

//Displaying the highest score
System.out.println("Highest Test Score :"+highest);

//displaying the list of students who are having highest scores
displayHighScoreStuds(st,highest);

  
   }

   //This method will display the list of students who are having highest scores
   private static void displayHighScoreStuds(StudentClass[] st, int highest) {
      
      
       for(int i=0;i<st.length;i++)
       {
           if(st[i].getTestScore()==highest)
           {
               System.out.println(st[i].getStudentLName()+", "+st[i].getStudentFName());
           }
       }
      
   }

   //This method will find the highest test score among all students
   private static int findHighestTestScore(StudentClass[] st) {
       int high=st[0].getTestScore();
       for(int i=0;i<st.length;i++)
       {
           if(high<st[i].getTestScore())
           {
               high=st[i].getTestScore();
           }
       }
       return high;
   }

   //This method will assign the grade letter to each student
   private static void assignGradeLetter(StudentClass[] st) {
      
   System.out.println("Student Name Test Score Grade");
   for(int i=0;i<st.length;i++)
   {
   if (st[i].getTestScore() >= 90)
   st[i].setGarde('A');
   else if (st[i].getTestScore() >= 80 && st[i].getTestScore() < 90)
   st[i].setGarde('B');
   else if (st[i].getTestScore() >= 70 && st[i].getTestScore() < 80)
   st[i].setGarde('C');
   else if (st[i].getTestScore() >= 60 && st[i].getTestScore() < 70)
   st[i].setGarde('D');
   else if (st[i].getTestScore()< 60)
   st[i].setGarde('F');
  
   }
   for(int i=0;i<st.length;i++)
   {
       System.out.printf("%s, %-10s %d %c ",st[i].getStudentLName(),st[i].getStudentFName(),st[i].getTestScore(),st[i].getGarde());
   }
   }

   //This method will read the data from the file nd populate into an array
   private static StudentClass[] readStudentsData(StudentClass[] st,Scanner sc) {
      
       String fname,lname;
       int grade;
       String str;
       int i=0;
   while(sc.hasNextLine())
   {
       str=sc.nextLine();
       String arr[]=str.split(" ");
       fname=arr[0];
       lname=arr[1];
       grade=Integer.parseInt(arr[2]);
       st[i++]=new StudentClass(fname,lname,grade);
         
   }
      
       return st;
   }

}

______________________

Output:

Student Name       Test Score   Grade
Donald, Duckey     85       B
Goofy, Goof     89       B
Balto, Brave    93       A
Smitn, Snow     93       A
Wonderful, Alice    89       B
Akthar, Samina     85       B
Green, Simba    95       A
Egger, Donald     90       A
Deer, Brown    86       B
Jackson, Johny    95       A
Gupta, Greg     75       C
Happy, Samuel     80       B
Arora, Danny    80       B
June, Sleepy     70       C
Cheng, Amy    83       B
Malik, Shelly     95       A
Tomek, Chelsea    95       A
Clodfelter, Angela     95       A
Nields, Allison    95       A
Norman, Lance    88       B


Highest Test Score :95
Green, Simba
Jackson, Johny
Malik, Shelly
Tomek, Chelsea
Clodfelter, Angela
Nields, Allison

_______________Could You rate me well .plz.Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote