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

Develop a Console Application related to a Grading application. This will give y

ID: 3669363 • Letter: D

Question

Develop a Console Application related to a Grading application. This will give you an opportunity to create a simple class and then use it.

1. Add a Student class to your project as shown in class.


2. Add the following private attributes to the Student class.
studentId which is an integer
studentName which is a string
examScore which is a double
projectScore which is a double

3. Provide the following 2 constructors for the Student class:

The first constructor takes no parameters and initializes the attributes studentId,
studentName, examScore, and projectScore to -100 and “n/a”, 0.0, and 0.0,
respectively.

The second constructor take the name and the id of the student as parameter and
initialize the studentName and studentId attributes to them respectively.

4. Provide the following public methods for the Student class:

computeTotalScore() that computes and returns the totalScore the student has earned in the course according to the following formula:

Total score = (examScore*60/100) + (projectScore*40/150)

computeGrade() that computes and returns the grade the student has earned in the course according to the following rules:
Total Score Grade
>= 90 A
[80, 90) B
<80 C
  
toString() that takes no parameters and returns a string containing the student’s id, name, exam score, project score, the grade (as determined above), and total score (as computed above) in the format that is same as the format of each student information line in the table shown in the sample output. Use String.Format() to format the string.

5. Provide get/set methods to read/write the examScore and projectScore attributes of the Student class.
The set method for examScore should not allow to set the examScore to a value less than 0 or a value strictly greater than 100.
The set method for projectScore should not allow to set the projectScore to a value less than 0 or a value strictly greater than 150.

6. Do the following in the main() method :

Instantiates 3 students, named “Fred”, “Bob”, and “Jill” with ids 1001, 1002 and 1003 respectively.
Set the examScore and projectScore for Fred to 95.5 and 140.5 respectively.
Set the examScore and projectScore for Bob to 85.0 and 135.5 respectively.
Set the examScore and projectScore for Jill to 75.5 and 120.0 respectively.
Display the table with student information as shown in the sample output.
Compute and display the average and maximum of the total scores of students as shown in the sample output.


Sample Output
Id Name Exam Project Total Grade
1001 Fred 95.5 140.5 94.8 A
1002 Bob 85.0 135.5 87. 1 B
1003 Jill 75.5 1 20.0 77.3 C
Average Total Score = 86.4
Maximum Total Score = 94.8

Explanation / Answer

Student.java

package assign3;

/**
* Student class to calculate the total score and grades
*
* @author yourName
*
*/
public class Student {
   private int studentId;
   private String studentName;
   private double examScore;
   private double projectScore;
   double totalScore = 0;
   String grade = "";

   // Constructor to initialize default values
   Student() {
       studentId = 100;
       studentName = "n/a";
       examScore = 0.0;
       projectScore = 0.0;
   }

   // Constructor to initialize the parameter values
   Student(String name, int id) {
       this.studentId = id;
       this.studentName = name;
   }

   // Method to calculate the total score
   public double computeTotalScore() {

       totalScore = (examScore * 60 / 100) + (projectScore * 40 / 150);
       return totalScore;
   }

   // Method to calculate the grade
   public String computeGrade() {
       if (totalScore >= 90) {
           grade = "A";
       } else if (totalScore >= 80 && totalScore < 90) {
           grade = "B";
       } else {
           grade = "C";

       }
       return grade;

   }

   // method to print the result
   public String toString() {
       return studentId + " " + studentName + " " + examScore + " "
               + projectScore + " " + String.format("%.1f", totalScore)
               + " " + grade;
   }

   /**
   * @return the examScore
   */
   public double getExamScore() {
       return examScore;
   }

   /**
   * @param examScore
   * the examScore to set
   */
   public void setExamScore(double examScore) {
       if (examScore > 0 && examScore <= 100) {
           this.examScore = examScore;
       } else {
           System.out.println("ExamScore is invalid");
       }
   }

   /**
   * @return the projectScore
   */
   public double getProjectScore() {
       return projectScore;
   }

   /**
   * @param projectScore
   * the projectScore to set
   */
   public void setProjectScore(double projectScore) {
       if (projectScore > 0 && projectScore <= 150) {
           this.projectScore = projectScore;
       } else {
           System.out.println("ProjectScore is invalid");
       }
   }

   // main method to run the program
   public static void main(String[] args) {
       double student1TotalScore = 0;
       double student2TotalScore = 0;
       double student3TotalScore = 0;
       double maxScore = 0;
       Student student1 = new Student("Fred", 1001);
       Student student2 = new Student("Bob", 1002);
       Student student3 = new Student("Jill", 1003);
       System.out.println("Id Name Exam Project Total Grade");
       student1.setExamScore(95.5);
       student1.setProjectScore(140.5);
       student1TotalScore = student1.computeTotalScore();
       student1.computeGrade();
       System.out.println(student1.toString());
       student2.setExamScore(85.0);
       student2.setProjectScore(135.5);
       student2TotalScore = student2.computeTotalScore();
       student2.computeGrade();
       System.out.println(student2.toString());
       student3.setExamScore(75.5);
       student3.setProjectScore(120.0);
       student3TotalScore = student3.computeTotalScore();
       student3.computeGrade();
       System.out.println(student3.toString());
       if (student1TotalScore > student2TotalScore
               && student1TotalScore > student3TotalScore) {
           maxScore = student1TotalScore;
       } else if (student2TotalScore > student1TotalScore
               && student2TotalScore > student3TotalScore) {
           maxScore = student2TotalScore;
       } else {
           maxScore = student3TotalScore;
       }
       System.out.println(" Average Total Score="
               + String.format("%.1f", (student1TotalScore
                       + student2TotalScore + student3TotalScore) / 3));
       System.out.println("Maximum Total Score="
               + String.format("%.1f", maxScore));
   }

}

Output:

Id   Name   Exam   Project   Total   Grade
1001   Fred   95.5   140.5   94.8   A
1002   Bob   85.0   135.5   87.1   B
1003   Jill   75.5   120.0   77.3   C

Average Total Score=86.4
Maximum Total Score=94.8

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