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

Create pseudocode for a program that computes a student’s test average. Design a

ID: 3681175 • Letter: C

Question

Create pseudocode for a program that computes a student’s test average. Design a program that prompts the user for a student’s ID number and three test scores. Each test score is to be entered with a separate prompt.

Output is the student’s average of the three test scores and the student’s grade. The grading scale is the usual scale:

Average

Grade

>= 90 and <=100

A

>= 80 and <90

B

>= 70 and < 80

C

>= 60 and < 70

D

<60

F

Use a Do/While loop. Assume there will be at least one input student and scores. After each student is processed, ask the user if there is more input and set a flag to “Y” or “N”. Allow for either capital letters or lower case letters.

Use a named constant for the number of tests (In this case 3).

Define a function named computeAverage() wirh 3 parameters all Real for each of the 3 tests. The function will return a Real value, the average of the 3 test scores.

Add a counter to count the number of students processed. Add a running total to accumulate the students’ averages. After the loop ends calculate the overall average by dividing the running total by the number of students.

Average

Grade

>= 90 and <=100

A

>= 80 and <90

B

>= 70 and < 80

C

>= 60 and < 70

D

<60

F

Explanation / Answer

Student.java

package com.test.chegg;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Student {
   private static int NUMBER_OF_TESTS = 3;
   private int id;
   private double t1;
   private double t2;
   private double t3;
   private double average;
   private char grade;

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       List<Student> studentList = new ArrayList<Student>();
       char ch = 0;
       int studentCounter = 0;
       double StudentsAverage = 0;
       do {
           Student student = new Student();
           System.out.println("Enter Student Id:");
           student.setId(sc.nextInt());
           System.out.println("Enter 1st test score");
           student.setT1(sc.nextDouble());
           System.out.println("Enter 2nd test score");
           student.setT2(sc.nextDouble());
           System.out.println("Enter 3rd test score");
           student.setT3(sc.nextDouble());

           double average = computeAverage(student.getT1(), student.getT2(),
                   student.getT3());

           student.setAverage(average);

           if (average >= 90 && average <= 100) {
               student.setGrade('A');
           } else if (average >= 80 && average < 90) {
               student.setGrade('B');
           } else if (average >= 70 && average < 80) {
               student.setGrade('C');
           } else if (average >= 60 && average < 70) {
               student.setGrade('D');
           } else if (average < 60) {
               student.setGrade('F');
           }
           studentList.add(student);
           StudentsAverage += average;
           studentCounter++;
           System.out
                   .println("Do you want enter another student info “Y” or “N”");
           ch = sc.next().charAt(0);
           average = 0;
       } while (ch == 'y' || ch == 'Y');

       // Displaying the Result
       System.out.println("StudentId Average Grade");
       for (Student student : studentList) {
           System.out.println(student.toString());
       }
       System.out
               .println(" Overall average" + StudentsAverage / studentCounter);
       sc.close();
   }

   /**
   * Method to compute the average
   *
   * @param t1
   * @param t2
   * @param t3
   * @return average
   */
   private static double computeAverage(double t1, double t2, double t3) {
       double average = 0;
       average = (t1 + t2 + t3) / NUMBER_OF_TESTS;
       return average;
   }

   /**
   * @return the id
   */
   public int getId() {
       return id;
   }

   /**
   * @param id
   * the id to set
   */
   public void setId(int id) {
       this.id = id;
   }

   /**
   * @return the t1
   */
   public double getT1() {
       return t1;
   }

   /**
   * @param t1
   * the t1 to set
   */
   public void setT1(double t1) {
       this.t1 = t1;
   }

   /**
   * @return the t2
   */
   public double getT2() {
       return t2;
   }

   /**
   * @param t2
   * the t2 to set
   */
   public void setT2(double t2) {
       this.t2 = t2;
   }

   /**
   * @return the t3
   */
   public double getT3() {
       return t3;
   }

   /**
   * @param t3
   * the t3 to set
   */
   public void setT3(double t3) {
       this.t3 = t3;
   }

   /**
   * @return the average
   */
   public double getAverage() {
       return average;
   }

   /**
   * @param average
   * the average to set
   */
   public void setAverage(double average) {
       this.average = average;
   }

   /**
   * @return the grade
   */
   public char getGrade() {
       return grade;
   }

   /**
   * @param grade
   * the grade to set
   */
   public void setGrade(char grade) {
       this.grade = grade;
   }

   /**
   * to string method to return the object info
   */
   public String toString() {
       return this.getId() + " " + String.format("%.2f", this.getAverage())
               + " " + this.getGrade();
   }
}

Output:

Enter Student Id:
1
Enter 1st test score
100
Enter 2nd test score
100
Enter 3rd test score
100
Do you want enter another student info “Y” or “N”
y
Enter Student Id:
2
Enter 1st test score
80
Enter 2nd test score
80
Enter 3rd test score
80
Do you want enter another student info “Y” or “N”
y
Enter Student Id:
3
Enter 1st test score
70
Enter 2nd test score
70
Enter 3rd test score
70
Do you want enter another student info “Y” or “N”
y
Enter Student Id:
4
Enter 1st test score
60
Enter 2nd test score
60
Enter 3rd test score
60
Do you want enter another student info “Y” or “N”
y
Enter Student Id:
5
Enter 1st test score
50
Enter 2nd test score
50
Enter 3rd test score
50
Do you want enter another student info “Y” or “N”
n
StudentId   Average   Grade
1       100.00   A
2       80.00   B
3       70.00   C
4       60.00   D
5       50.00   F

Overall average72.0

PseudoCode:

Step 1: Construct a new 'Scanner' object.

Step 2: Initialize an char(say ch),an int.(say ch),an double.(say studentCounter),an char .(say StudentsAverage),an int.(say id),an double.(say t1),an double.(say t2),an double.(say t3),an double(say average),an char (say grade)

Step 3:Create Accessor/Muttator method for id,t1,t2,t3,average,grade

Step 4: BEGIN LOOP

Construct a new 'Student' object.
      
   Print Enter student id
Read student Id

   Print Enter 1st test score
Read t1

   Print Enter 2nd test score
Read t2

   Print Enter 3rd test score
Read t3
  
   Call 'computeAverage' method with 't1,t2,t3' as argument.
set average to student object

IF 'average>=90' and 'average<=100'
       set grade as 'A' to student object
     
    ELSE IF 'average>=80' and 'average<90'
       set grade as 'B' to student object
   
ELSE IF 'average>=70' and 'average<80'
       set grade as 'C' to student object
  
ELSE IF 'average>=60' and 'average<70'
       set grade as 'D' to student object
  
ELSE IF 'average<60'
       set grade as 'F' to student object
END IF

   add student object to list
     
studentsAverage=studentsAverage+average
      
increment studentcounter

   print Do you want enter another student info “Y” or “N”
     
   reset average to 0
   Read choice

END LOOP
  
   print the student details
  
   print overall average

   STOP

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote