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 java program (use value returning method) that gives simple math quizzes. The program should...
Write a java program (use value returning method) that gives simple math quizzes. The program should display two random integers from 1 to 100 that are to be added, such as:    47 + 29 The program allows the user to enter the answer. If the answer is correct, display “congratulations”. If the answer is incorrect, the program should show the correct answer. Your result should look like, for example:    47 + 29 Enter your answer: 1 Wrong, the right answer...
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...
Define a class for the student record. The class should instance variables for Quizzes, Midterm, Final...
Define a class for the student record. The class should instance variables for Quizzes, Midterm, Final and total score for the course and final letter grade. The class should have input and output methods. The input method should not ask for the final numeric grade, nor should it ask for final letter grade. The classes should have methods to compute the overall numeric grade and the final letter grade. These two methods will be void methods that set the appropriate...
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;...
Write a program that meets the following requirements: Cat Class Create a class called Cat which...
Write a program that meets the following requirements: Cat Class Create a class called Cat which has only the following instance variables: - name - breed - number of legs - year born Create the no-argument constructor Create the constructor which uses all fields as parameters Write the getter and setter methods for all instance variables Override the toString method using the example shown above There should be NO main method in the Cat class. CatTester Class Create a class...
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...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT