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

write a grading program on terminal with the result for a class with the followi

ID: 3856239 • Letter: W

Question

write a grading program on terminal with the result for a class with the following grading policies.

1. there are 2 quizzes, each graded on the basis of 10 points.

2. there is 1 midterm test and one final test , each graded on the basis of 100 points.

3. the final test counts for 50% of the grade, the midterm counts for 25%, and the 2 quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores.)

A letter grade will be given based on the following criterion:

90 – 100 A

80 – 89 B

70 – 79 C

60 – 69 D

0 – 59 E

The program will read in the student’s scores from a text file, and output the student’s record, which consists of the name, 2 quiz and 2 test scores as well as the student’s average numeric score for the entire course and final letter grade.

Define and use a class for the student record. All the scores are integers and a student name consists of no more than 10 characters.

You must justify your output file.

Explanation / Answer

import java.io.*;
class Student
{
String student_name;
int quiz_mark1,quiz_mark2,mid_mark,final_mark;
int normalised_mark;
char grade;
Student(String name,int quiz1,int quiz2,int mid_term,int final_test)
{
   student_name = name;
   quiz_mark1 = quiz1;
   quiz_mark2 = quiz2;
   mid_mark = mid_term;
   final_mark = final_test;
}
void calculate_marks_grade()
{
   float quiz_normalised,mid_normalised,final_normalised;
   quiz_normalised = (quiz_mark1 + quiz_mark2)*5*25/100;
   mid_normalised = mid_mark/4;
   final_normalised = final_mark/2;
   normalised_mark = Math.round(quiz_normalised + mid_normalised + final_normalised);
   if(normalised_mark >= 90)
   {
       grade = 'A';
   }
   else if(normalised_mark >= 80 && normalised_mark <= 89)
   {
       grade = 'B';
   }
   else if(normalised_mark >= 70 && normalised_mark <= 79)
{
grade = 'C';
}
   else if(normalised_mark >= 60 && normalised_mark <= 69)
{
grade = 'D';
}
   else if(normalised_mark >= 0 && normalised_mark <= 59)
{
grade = 'E';
}

      
}
  
}

class Grading
{
public static void main(String s[])throws Exception
{
FileInputStream fstream = new FileInputStream("input.txt");
  
DataInputStream in = new DataInputStream(fstream);

BufferedReader br = new BufferedReader(new InputStreamReader(in));
BufferedWriter bw = null;
FileWriter fw = null;
Student st[] = new Student[100];
int no_of_students=0;
try{
String line = br.readLine();   
if(line==null)
throw new IOException();

no_of_students = Integer.parseInt(line); //Assuming first line in the input file is number of students
for(int i = 0; i < no_of_students; i++){
String name = br.readLine();
int quiz1 = Integer.parseInt(br.readLine());
int quiz2 = Integer.parseInt(br.readLine());
int mid_term = Integer.parseInt(br.readLine());
   int final_test = Integer.parseInt(br.readLine());
st[i] = new Student(name,quiz1,quiz2,mid_term,final_test);
}

in.close();
}catch(IOException e){
System.out.println(e);
}
  
  
try {
       fw = new FileWriter("output.txt");
       bw = new BufferedWriter(fw);
       for(int i = 0; i < no_of_students; i++)
   {
           st[i].calculate_marks_grade();
       bw.write( "Name: "+st[i].student_name + " Grade : " + st[i].grade + " normalised marks : "+st[i].normalised_mark+" ");
   }
       bw.close();
   } catch (IOException e){}
   }
}