I want an A! Write a pseudocode algorithm that asks the user for their grades in CSE 1321, along with their attendance, then calculates their final grade. Note, perfect attendance rounds up your final grade by 1.5 points – otherwise, it’s a fraction out of 30. The tests and quiz average are worth 20% each

Respuesta :

Answer:

The Java pseudocode and the Java code itself are given for better understanding

Explanation:

Java pseudocode

  1. preAvg(int test[], int qgrade):
  2. sum := 0
  3. for each testi in test:
  4. sum := sum + testi
  5. sum := sum + qgrade
  6. return sum / 5
  7. additional(int at):
  8. res = (at * 1.5) / 30
  9. return res
  10. total = preAvg(test, qgrade) + additional(at)

Java code

import java.util.Scanner;

public class CSE1322 {

  public static void main(String[] args) {

     

      Scanner scanner=new Scanner(System.in);

     

      int test[] = new int[4];

     

      for(int i=1;i<=4;i++){

          System.out.println("Enter your result for test"+i+": ");

          test[i-1] = scanner.nextInt();

      }

     

      System.out.println("Enter the average quiz grade: ");

      int qgrade = scanner.nextInt();

     

      System.out.println("Enter the classes you attended(out of 30): ");

      int at = scanner.nextInt();

     

      double avg = preAvg(test,qgrade);

      System.out.println("Your average before attendance is: "+avg);

     

      double add = additional(at);

      System.out.println("You receive an additional "+add+" points for attendance");

     

      double total = avg + add;

     

      System.out.println("Final grade is : "+total);

     

  }

  private static double additional(int at) {

      double res = ((double)at * 1.5)/30.0;

      return res;

  }

  private static double preAvg(int[] test, int qgrade) {

      double sum = 0;

     

      for(int i=0;i<4;i++) sum += test[i];

     

      sum += qgrade;

     

      return sum/5;

  }

}