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

2. (a) Implement a class Student. For the purpose of this exercise, a student ha

ID: 662838 • Letter: 2

Question

2. (a) Implement a class Student. For the purpose of this exercise, a student has
a name and a total quiz score. Supply an appropriate constructor and methods
getName(), addQuiz(score), getTotalScore(), and getAverageScore(). To compute
the latter, you also need to store the number of quizzes that the student took.
(b) Modify the Student class to compute grade point averages. Methods are needed
to add a grade and get the current GPA. Specify grades as elements of a class
Grade. Supply a constructor that constructs a grade from a string, such as "B+".
You will also need a method that translates grades into their numeric values (for
example, "B+" becomes 3.3). [You may obtain traditional grading scales from here
http://en.wikipedia.org/wiki/Academic_grading_in_the_United_States]

Explanation / Answer

Below there are two programs:::

Student.java

import java.util.Scanner;


public class Student {

   public String name;
   int score=0;
   int quizno;
   public Student(String name,int quizno) {
       this.name=name;
       this.quizno=quizno;
      
   }

   public String getName()
   {
       return this.name;
   }
  
   public void addQuiz(int score)
   {
   this.score=this.score+score;
   }
  
   public int getTotalScore()
   {
       return this.score;
   }
  
   public float getAverageScore()
   {
       float averagescore=this.score/this.quizno;
       return averagescore;
   }
   public static void main(String[] args) {
   Scanner scan=new Scanner(System.in);
   System.out.println("please enter your name to participate in quiz....");
   String name=scan.next();
  
   System.out.println("enter how many quizs you want to participate......");
   int quizno=scan.nextInt();
   Student student=new Student(name, quizno);
   for (int i = 0; i < quizno; i++) {
       System.out.println("please enter your "+(i+1)+" quiz marks...........");
       int score=scan.nextInt();
       student.addQuiz(score);
   }
   System.out.println("Total Score of "+name+" is "+student.getTotalScore());
   System.out.println("Average Score of "+name+" is "+student.getAverageScore());
   float averagescore=student.getAverageScore();
  
   System.out.println("******************GRADING SYSTEM*******************");
  
   if(averagescore>=93 && averagescore<100)
   {
       System.out.println(name+ " your grade is A+ with GPA:::: " +Grade.A);
   }
   else if(averagescore>=90 && averagescore<=92)
   {
       System.out.println(name+ " your grade is A- with GPA:::: " +Grade.Aminus);
   }
   else if(averagescore>=87 && averagescore<=89)
   {
       System.out.println(name+ " your grade is B+ with GPA:::: " +Grade.Bplus);
   }
  
   else if(averagescore>=83 && averagescore<86)
   {
       System.out.println(name+ " your grade is B with GPA:::: " +Grade.B);
   }
  
   else if(averagescore>=80 && averagescore<=82)
   {
       System.out.println(name+ " your grade is B- with GPA:::: " +Grade.Bminus);

   }
   else if(averagescore>=77 && averagescore<=79)
   {
       System.out.println(name+ " your grade is C+ with GPA:::: " +Grade.cplus);

   }
   else if(averagescore>=70 && averagescore<=76)
   {
       System.out.println(name+ " your grade is C with GPA:::: " +Grade.c);

   }
   else if(averagescore>=60 && averagescore<=69)
   {
       System.out.println(name+ " your grade is D with GPA:::: " +Grade.d);

   }
   else if(averagescore>=0 && averagescore<=59)
   {
       System.out.println(name+ " your grade is F with GPA:::: " +Grade.f);

Grade.java

public class Grade
{
   public static float A=4.0f;
   public static float B=3.0f;
   public static float c=2.0f;
   public static float d=1.0f;
   public static float f=0.0f;
   public static float Aminus=3.67f;
   public static float Bplus=3.33f;
   public static float Bminus=2.67f;
   public static float cplus=2.33f;
   }

OUTPUT::::::::::

please enter your name to participate in quiz....
sowji
enter how many quizs you want to participate......
4
please enter your 1 quiz marks...........
80
please enter your 2 quiz marks...........
70
please enter your 3 quiz marks...........
90
please enter your 4 quiz marks...........
95
Total Score of sowji is 335
Average Score of sowji is 83.0
******************GRADING SYSTEM*******************
sowji your grade is B with GPA:::: 3.0

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote