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

Create a class called Student that has: - A field to store the name - A field to

ID: 649627 • Letter: C

Question

 Create a class called Student that has:  - A field to store the name  - A field to store their average number grade  - A field to store their grade (A, B, C etc.)  - A constructor that sets information in all the fields  - Appropriate accessor methods  Write a main class that asks the user the number of students in the class (n). Then prompt for the information for all students and create a Student object for each one. Use an ArrayList to store all the Student objects created. After all the data is entered, display a neatly formatted gradebook, with the averages rounded to 1 decimal place:  Example Output:           Name         |    Average  |    Grade            Stew Dent    |       78.3  |        C           Joe Schmoe   |       91.1  |        A           .           .           .           ...up to n students  JAVA PROGRAM HELP  

Explanation / Answer

import java.util.*;

class Students{
private String name;
   private double average;
   private char grade;
  
   Students(String n, double ave, char gra){
   name = n;
       average = ave;
       grade = gra;
   }
  
   String getName(){
   return name;
   }
  
   double getAverage(){
   return average;
   }
  
   char getGrade(){
   return grade;
   }
}

class Demo{
public static void main(String []args){
   int n;
       Scanner in = new Scanner(System.in);
       String name;
       double average;
       char grade;
      
       System.out.print("Enter the number of students : ");
       n = in.nextInt();
      
       ArrayList<Students> arr = new ArrayList<Students>();
      
       for(int i=0; i< n; i++){
       in.nextLine();
       System.out.print("Enter name of student : ");
           name = in.nextLine();
           System.out.print("Enter average of student : ");
           average = in.nextDouble();
           System.out.print("Enter grade of student : ");
           grade = in.next().charAt(0);
          
           Students s = new Students(name, average, grade);
          
           arr.add(s);
       }
      
       System.out.println(" Name Average Grade ");
       for(int i = 0; i< n; i++){
       name = arr.get(i).getName();
           average = arr.get(i).getAverage();
           grade = arr.get(i).getGrade();
          
           System.out.println(name + " | " + average + " | " + grade + " ");
       }
   }
}

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