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

NEEDS TO BE WRITTEN IN JAVA , USING OBJECT ORIENTED PROGRAMMING Problem : Suppos

ID: 3808563 • Letter: N

Question

NEEDS TO BE WRITTEN IN JAVA , USING OBJECT ORIENTED PROGRAMMING

Problem : Suppose at the end of the semester, there is a file "scores.dat" recording scores each student has earned so far from closed lab assignments (CLA), open lab assignments (OLA), quizzes, exams, and final exam score. You can assume there are no more than 30 students. The final letter grade is decided according to the following table based on the total points they have earned:

Total Points

Final Letter Grade

Total Points

Final Letter Grade

>=90

A

>=70, but <73

C-

>=87, but <90

B+

>=67, but <70

D+

>=83, but <87

B

>=63, but <67

D

>=80, but <83

B-

>=60, but <63

D-

>=77, but <80

C+

<60

F

>=73, but <77

C

In this assignment, you are asked to write a program to calculate student final letter grades as well as the average and highest scores of CLA, OLA, quizzes, exams, and final exam scores. The final result should be printed to the screen (standard output).

Requirements:

At the beginning of the program, your program should give the user a prompt for the name of the data file which contains the records of student grades.

Define a class Student, which includes student id, scores for CLA, OLA, quizzes, exams, final scores, total points, and letter grade. All member data must be private. The class must provide a function to calculate the final letter grade.

Store all Student objects in an associative array (other similar data structures like map, hash map are also fine) so that we can lookup student final letter grade by C#.

Your program should allow users to perform two queries. For each query, the user inputs C#, and your program should print all information (including his/her final letter grade) of the student with the given C#. After two queries, your program print information of all students on the screen.

If the language doesn’t support object-oriented programming or associative array, then use appropriate data structures.

If the language doesn’t support file input, you can store them in your program.

Make sure that your program has the proper documentation (program heading, variable explanation, description/input/output for each user defined function, explanation for logically related statements, etc), and style for good program readability and modifiability. Refer to the back page for more details on program requirements your program should follow.

This is the file:

C# CLA OLA Quiz Exam FinalExam
c1234501 10 20    10 30 30
c1234502 9 10 5 20 20
c1234503 10 17 8 27 27
c1234504 8 14 10 29 15
c1234505 7 18 3 24 27
c1234506 8 16 9 13 14
c1234507 6 11 5 27 26
c1234508 8 15 9 17 28
c1234509 5 19 8 28 29
c1234510 9 14 6 19 19
c1234511 2 6 4 17 19
c1234512 7 18 7 22 25
c1234513 4 10 9 11 19
c1234514 8 18 8 24 19
c1234515 7 13 7 20 20
c1234516 10 19 9 19 19
c1234517 8 10 9 19 24
c1234518 6 11 7 23 25
c1234519 4 8 4 19 20
c1234520 9 15 9 22 24
c1234521 10 13 10 20 30
c1234522 10 12 10 25 25

Total Points

Final Letter Grade

Total Points

Final Letter Grade

>=90

A

>=70, but <73

C-

>=87, but <90

B+

>=67, but <70

D+

>=83, but <87

B

>=63, but <67

D

>=80, but <83

B-

>=60, but <63

D-

>=77, but <80

C+

<60

F

>=73, but <77

C

Explanation / Answer

//please add student record through program and add some validation where i didnot write

//Code is working fine!!


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Student {

   //Declaring the required variables with constructor and ToString method followed by getters and setters
   private String StudentId;
   private float CLAscore;
   private float OLAscore;
   private float Quizscore;
   private float Examscore;
   private float Finalscore;
   private float Totalscore;
   private String Grade;
  
   public String getStudentId() {
       return StudentId;
   }

   public void setStudentId(String studentId) {
       StudentId = studentId;
   }

   public float getCLAscore() {
       return CLAscore;
   }

   public void setCLAscore(float cLAscore) {
       CLAscore = cLAscore;
   }

   public float getOLAscore() {
       return OLAscore;
   }

   public void setOLAscore(float oLAscore) {
       OLAscore = oLAscore;
   }

   public float getQuizscore() {
       return Quizscore;
   }

   public void setQuizscore(float quizscore) {
       Quizscore = quizscore;
   }

   public float getExamscore() {
       return Examscore;
   }

   public void setExamscore(float examscore) {
       Examscore = examscore;
   }

   public float getFinalscore() {
       return Finalscore;
   }

   public void setFinalscore(float finalscore) {
       Finalscore = finalscore;
   }

   public float getTotalscore() {
       return Totalscore;
   }

   public void setTotalscore(float totalscore) {
       Totalscore = totalscore;
   }

   public String getGrade() {
       return Grade;
   }

   public void setGrade(String grade) {
       Grade = grade;
   }

   //Constructor
   public Student(String studentId, float cLAscore, float oLAscore, float quizscore, float examscore, float finalscore,
           float totalscore, String grade) {
       super();
       StudentId = studentId;
       CLAscore = cLAscore;
       OLAscore = oLAscore;
       Quizscore = quizscore;
       Examscore = examscore;
       Finalscore = finalscore;
       Totalscore = totalscore;
       Grade = grade;
   }
  
   //Class Constructor
   public Student(){}
  
  
   //Class ToString
   @Override
   public String toString() {
       return "Student [StudentId=" + StudentId + ", CLAscore=" + CLAscore + ", OLAscore=" + OLAscore + ", Quizscore="
               + Quizscore + ", Examscore=" + Examscore + ", Finalscore=" + Finalscore + ", Totalscore=" + Totalscore
               + ", Grade=" + Grade + "]";
   }
  
   //Main Function
   @SuppressWarnings("null")
   public static void main(String[] args) {
       //Instantiating the constructor of Student class to use the methods in student class
       Student student = new Student();
       Student student1 = new Student("c1234501", 10, 20, 10, 30, 30, student.TotalMarks(10, 20, 10, 30, 30), student.Grade(student.TotalMarks(10, 20, 10, 30, 30)));
       Student student2 = new Student("c1234502", 9, 10, 5, 20, 20, student.TotalMarks(9, 10, 5, 20, 20), student.Grade(student.TotalMarks(9, 10, 5, 20, 20)));
       Student student3 = new Student("c1234503", 10,17,8,27,27,student.TotalMarks( 10,17,8,27,27), student.Grade(student.TotalMarks( 10,17,8,27,27)));
       Student student4 = new Student("c1234504", 8,14,10,29,15,student.TotalMarks( 8,14,10,29,15), student.Grade(student.TotalMarks( 8,14,10,29,15)));
       Student student5 = new Student("c1234505", 7,18,3,24,27,student.TotalMarks(7,18,3,24,27), student.Grade(student.TotalMarks( 7,18,3,24,27)));
       Student student6 = new Student("c1234506", 8,16,9,13,14,student.TotalMarks(8,16,9,13,14), student.Grade(student.TotalMarks( 8,16,9,13,14)));
       Student student7 = new Student("c1234507", 6,11,5,27,26,student.TotalMarks(6,11,5,27,26), student.Grade(student.TotalMarks( 6,11,5,27,26)));
       Student student8 = new Student("c1234508", 8,15,9,17,28,student.TotalMarks(8,15,9,17,28), student.Grade(student.TotalMarks( 8,15,9,17,28)));
       Student student9 = new Student("c1234509", 5,19,8,28,29,student.TotalMarks(5,19,8,28,29), student.Grade(student.TotalMarks( 5,19,8,28,29)));
       Student student10 = new Student("c1234510", 9,14,6,19,19,student.TotalMarks(9,14,6,19,19), student.Grade(student.TotalMarks( 9,14,6,19,19)));
      
      
      
      
       //Please add the remaining students the same way I added above!!
      
      
       //Preparation of Map
      
       Map<String, Student> map = new HashMap<String, Student>();
       map.put("c1234501", student1);
       map.put("c1234502", student2);
       map.put("c1234503", student3);
       map.put("c1234504", student4);
       map.put("c1234505", student5);
       map.put("c1234506", student6);
       map.put("c1234507", student7);
       map.put("c1234508", student8);
       map.put("c1234509", student9);
       map.put("c1234510", student10);
       @SuppressWarnings("resource")
       Scanner input = new Scanner( System.in );
       System.out.println("Please pick one ");
       System.out.println("1. See the record of student score ");
       System.out.println("2. Average of CLA, OLA, quizzes, exams, and final exam scores");
       System.out.println("3. highest of CLA, OLA, quizzes, exams, and final exam scores");
      
       int option = Integer.parseInt(input.nextLine());
       if(option==1){
           //taking input from keyboard
       @SuppressWarnings("resource")
           Scanner scanner = new Scanner( System.in );
       System.out.println("Please Enter C#: ");

       //storing the input into string
       String inputId = scanner.nextLine();
      
       Student FetchedStudentRecord= map.get(inputId);
      
       if(FetchedStudentRecord==null){System.out.println("No records found");}
       else{System.out.println(map.get(inputId));}
       }
       if(option==2){
          
      
           @SuppressWarnings("resource")
           Scanner scanner1 = new Scanner( System.in );
       System.out.println("What score you want the average: ");
       System.out.println("1.CLA");
       System.out.println("2.OLA");
       System.out.println("3.Quiz");
       System.out.println("4.Exam");
       System.out.println("5.finalExam");
      
       //take input from keyboard
       int input1 = Integer.parseInt(scanner1.nextLine());
          
          
       //reverse map to get the student record
       Map<Student ,String> ReversedMap = new HashMap<>();

       for(Map.Entry<String, Student> entry : map.entrySet()){
           ReversedMap.put(entry.getValue(), entry.getKey());
       }

       Set<Student> set = new HashSet<>( ReversedMap.keySet());
      
       List<Student> lst = new ArrayList<Student>(set);

          

       List<Float> list = new ArrayList<Float>() ;
      
      
       //find the average of the score based on the exam requirement

       if(input1==1){

           for (int i = 0; i < lst.size(); i++) {
              
              
               list.add(new Float(lst.get(i).getCLAscore()));
           }
           int sum = 0;

           for(Float i: list) {
               sum += i;
           }
           System.out.println(sum/lst.size());
       }
       if(input1==2){

           for (int i = 0; i < lst.size(); i++) {

               list.add(new Float(lst.get(i).getOLAscore()));
           }
           int sum = 0;

           for(Float i: list) {
               sum += i;
           }
           System.out.println(sum/lst.size());
       }
       if(input1==3){

           for (int i = 0; i < lst.size(); i++) {

               list.add(new Float(lst.get(i).getQuizscore()));
           }
           int sum = 0;

           for(Float i: list) {
               sum += i;
           }
           System.out.println(sum/lst.size());
       }
       if(input1==4){

           for (int i = 0; i < lst.size(); i++) {

               list.add(new Float(lst.get(i).getExamscore()));
           }
           int sum = 0;

           for(Float i: list) {
               sum += i;
           }
           System.out.println(sum/lst.size());
       }
       if(input1==5){

           for (int i = 0; i < lst.size(); i++) {

               list.add(new Float(lst.get(i).getFinalscore()));
           }
           int sum = 0;

           for(Float i: list) {
               sum += i;
           }
           System.out.println(sum/lst.size());
       }

      

          
       }
       if(option==3){
          
               @SuppressWarnings("resource")
               Scanner scanner1 = new Scanner( System.in );
           System.out.println("What score you want the higest: ");
           System.out.println("1.CLA");
           System.out.println("2.OLA");
           System.out.println("3.Quiz");
           System.out.println("4.Exam");
           System.out.println("5.finalExam");
          
           //take input from keyboard
           int input1 = Integer.parseInt(scanner1.nextLine());
              
              
           Map<Student ,String> ReversedMap = new HashMap<>();

           for(Map.Entry<String, Student> entry : map.entrySet()){
               ReversedMap.put(entry.getValue(), entry.getKey());
           }

           @SuppressWarnings("unchecked")
               List<Student> lst = (List<Student>) ReversedMap.keySet();


           List<Float> list = null ;
           //find the average of each of the exam based on requirement

           if(input1==1){

               for (int i = 0; i < lst.size(); i++) {

                   list.add(lst.get(i).getCLAscore());
               }
               Object obj = Collections.max(list);

               System.out.println(obj);
           }
           if(input1==2){

               for (int i = 0; i < lst.size(); i++) {

                   list.add(lst.get(i).getOLAscore());
               }
               Object obj = Collections.max(list);

               System.out.println(obj);
           }
           if(input1==3){

               for (int i = 0; i < lst.size(); i++) {

                   list.add(lst.get(i).getQuizscore());
               }
               Object obj = Collections.max(list);

               System.out.println(obj);
           }
           if(input1==4){

               for (int i = 0; i < lst.size(); i++) {

                   list.add(lst.get(i).getExamscore());
               }
               Object obj = Collections.max(list);

               System.out.println(obj);
           }
           if(input1==5){

               for (int i = 0; i < lst.size(); i++) {

                   list.add(lst.get(i).getFinalscore());
               }
               Object obj = Collections.max(list);

               System.out.println(obj);
           }

           else{System.out.println("please pick the correct option");}

          
          
          
       }
       if(option!=1&&option!=2&&option!=3){System.out.println("please pick the correct option from 1-3");}
      
      
      
      

      
   }
  
   //Finding total marks
   public float TotalMarks(float cLAscore, float oLAscore, float quizscore, float examscore, float finalscore){
       return cLAscore+oLAscore+quizscore+examscore+finalscore;
   }
  
   //Finding grade based on requirement
   public String Grade(float totalMarks){
      
       if(totalMarks>=90) return "A";
       if(totalMarks>=87 && totalMarks<90) return "B+";
       if(totalMarks>=83 && totalMarks<87) return "B";
       if(totalMarks>=80 && totalMarks<83) return "B-";
       if(totalMarks>=77 && totalMarks<80) return "C+";
       if(totalMarks>=73 && totalMarks<77) return "C";
       if(totalMarks>=70 && totalMarks<73) return "C-";
       if(totalMarks>=67 && totalMarks<70) return "D+";
       if(totalMarks>=63 && totalMarks<67) return "D";
       if(totalMarks>=60 && totalMarks<63) return "D-";
       if(totalMarks<60) return "F";
      
       return null;
   }
  
  
}