Question

In: Computer Science

Write a grading program for a class with the following grading policies: There are three quizzes,...

Write a grading program for a class with the following grading policies:

  1. There are three quizzes, each graded on the basis of 10 points.

  2. There is one miterm exm, graded on the basis of 100 points.

  3. There is one finl exm, graded on the basis of 100 points.

The fnal exm counts for 40% of the grade. The miterm counts for 35% of the grade. The three quizzes together count for a total of 25% of the grade. (Do not forget to convert the quiz scores to percentages before they are averaged in.)

Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and any grade below 60 is an F. The program should read in the student’s scores and output the student’s record, which consists of three quiz scores and two exm scores, as well as the student’s overall numeric score for the entire course and final letter grade.

Define and use a class for the student record. The class should have instance variables for the quizzes, midterm, final, overall numeric score for the course, and final letter grade. The overall numeric score is a number in the range 0 to 100, which represents the weighted average of the student’s work. The class should have methods to compute the overall numeric grade and the final letter grade. These last methods should be void methods that set the appropriate instance variables. Your class should have a reasonable set of accessor and mutator methods, an equals method, and a toString method, whether or not your program uses them. You may add other methods if you wish.

JAVA!

Solutions

Expert Solution

Have a look at the below code. I have put comments wherever required for better understanding.

class Student{
  // instance variables
  int quiz1,quiz2,quiz3;
  int midSem;
  int finalExam;
  int overallScore;
  char grade;
  // setters
  public void setQuiz1(int x){
    this.quiz1 = x;
  }

  public void setQuiz2(int y){
    this.quiz2 = y;
  }

  public void setQuiz3(int z){
    this.quiz2 = z;
  }

  public void setmidSem(int m){
    this.midSem = m;
  }

  public void setFinalExam(int f){
    this.finalExam = f;
  }

  // getters

  public int getQuiz1(){
    return this.quiz1;
  }

  public int getQuiz2(){
    return this.quiz2;
  }

  public int getQuiz3(){
    return this.quiz3;
  }

  public int getmidSem(){
    return this.midSem;
  }

  public int getFinalExam(){
    return this.finalExam;
  }

  public int getOverallScore(){
    return this.overallScore;
  }

  public int getGrade(){
    return this.grade;
  }

  public int quizAverage(){
    int total = 0;

    total+= (this.quiz1/10)*100;
    total+= (this.quiz2/10)*100;
    total+= (this.quiz2/10)*100;

    return total/3;
  }

  public int overAll(){
    int total = 0;

    total+=0.4*finalExam;
    total+=0.35*midSem;
    total+=0.25*quizAverage();

    return total;
  }

  public setGrade(){
    int finalScore = overAll();

    if (finalScore>=90){
      this.grade = 'A';
    }
    else if(finalScore>=80){
      this.grade = 'B';
    }
    else if(finalScore>=70){
      this.grade = 'C';
    }
    else if(finalScore>=60){
      this.grade = 'D';
    }
    else{
      this.grade = 'F';
    }

  }

  public String toString(){//overriding the toString() method  
  return quiz1 + quiz2 + quiz3 + midSem + finalExam;  
 }  

}

Happy Learning!


Related Solutions

write a program called GradeCalculator that will calculate the grading statistics of a desired number of...
write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will also check for negative scores. If any...
Write C++ program Consider the following SimpleString class: class simpleString {     public:          simpleString( );...
Write C++ program Consider the following SimpleString class: class simpleString {     public:          simpleString( );                                 // Default constructor          simpleString(int mVal );                    // Explicit value constructor          ~simpleString() { delete [ ] s;}          // Destructor void readString();                              // Read a simple string          void writeString() const;                    // Display a simple string char at(int pos) const;                       // Return character at (pos)          int getLength() const;                        // Return the string length          int getCapacity() const;...
Please write this program in C++ Write a program that           - a user-defined class Cuboid...
Please write this program in C++ Write a program that           - a user-defined class Cuboid which has the following elements:                    - default constructor (has no parameters)                    - constructor that has 3 parameters (height, length, width)                    - data members                              - height, length, width                    - member functions                              - to set the value of each of the data members - 3 functions                              - to get the value of each of the data members - 3...
Write a program in java that does the following: Create a StudentRecord class that keeps the...
Write a program in java that does the following: Create a StudentRecord class that keeps the following information for a student: first name (String), last name (String), and balance (integer). Provide proper constructor, setter and getter methods. Read the student information (one student per line) from the input file “csc272input.txt”. The information in the file is listed below. You can use it to generate the input file yourself, or use the original input file that is available alone with this...
Twenty calculus students are comparing grades on their first two quizzes of the year. The class...
Twenty calculus students are comparing grades on their first two quizzes of the year. The class discovers that every pair of students received the same grade on at least one of the two quizzes. Prove that the entire class received the same grade on at least one of the two quizzes.
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...
Part A: Create a project with a Program class and write the following two methods (headers...
Part A: Create a project with a Program class and write the following two methods (headers provided) as described below: A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range or a non-numeric...
write program that develop a Java class Dictionary to support the following public methods of an...
write program that develop a Java class Dictionary to support the following public methods of an abstract data type: public class Dictionary { // insert a (key, value) pair into the Dictionary, key value must be unique, the value is associated with the key; only the last value inserted for a key will be kept public void insert(String key, String value); // return the value associated with the key value public String lookup(String key); // delete the (key, value) pair...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following two methods(headers provided) as described below: 1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range...
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT