Site Loader

// Bridget Haney// 1/28/18// CSE 142// TA: Aidan Hunt (AN)// Assignment 4: Gradanator//// produces a grade calculator that takes into account// weighted scores, including for one midterm, one final, // homework assignments, and section attendance.import java.util.*;public class Gradanator {      public static final int TEST_SCORE = 100;   public static final int SECTION_SCORE = 30;   public static void main(String args) {   Scanner console = new Scanner(System.in);        openingMessage();        double midterm = testCalculations(“Midterm”, console, TEST_SCORE);        double finalScore = testCalculations(“Final”, console, TEST_SCORE);        double homework = homeworkScore(console);        gpaCalculator(midterm, finalScore, homework);   }   //produces the opening message of the gradanator   public static void openingMessage() {      System.out.println(“This program reads exam/homework scores”);      System.out.println(“and reports your overall course grade.”);      System.out.println();   }   public static double testCalculations(String test, Scanner console, int TEST_SCORE) {     System.out.println(test + “: “);     System.out.print(“Weight (0-100?) “);            int weight = console.nextInt();      double totalWeight = weight;      System.out.print(“Score earned? “);      int score = console.nextInt();      System.out.print(“Were scores shifted (1=yes, 2=no)? “);      int shift = console.nextInt();      int amountShifted;      if (shift == 1) {         System.out.print(“Shift amount? “);         amountShifted = console.nextInt();      } else {         amountShifted = 0;      }      score = score + amountShifted;      if (score > TEST_SCORE) {         score = TEST_SCORE;      } else {         score = score;      }      System.out.println(“Total points = ” + score + ” / ” + TEST_SCORE);      double total = TEST_SCORE;      double earned = score;      double weightedScore = totalWeight / TEST_SCORE * score;      double weightedTotal = totalWeight / TEST_SCORE * total;      int weightedTotalScore = (int)weightedTotal;      System.out.printf(“Weighted score = %.1f / ” + weightedTotalScore, weightedScore);      System.out.println();      System.out.println();      return weightedScore;    }   //produces the homework scores   public static double homeworkScore(Scanner console) {     System.out.println(“Homework:”);     System.out.print(“Weight (0-100)? “);     double weight = console.nextInt();     int secondWeight = (int)weight;     System.out.print(“Number of assignments? “);     double assignments = console.nextInt();     int score = 0;     int max = 0;     for (int i = 1; i <= assignments; i++) {         System.out.print("Assignment " + i + " score and max? ");         score = score + console.nextInt();         max = max + console.nextInt();     }     System.out.print("How many sections did you attend? ");     int attendanceRate = console.nextInt() * 5;     if (attendanceRate > SECTION_SCORE) {         attendanceRate = SECTION_SCORE;     } else {      attendanceRate = attendanceRate;     }     System.out.println(“Section points = ” + attendanceRate + ” / ” + SECTION_SCORE);     score = score + attendanceRate;     max = max + SECTION_SCORE;     if (score > max) {        score = max;     } else {        score = score;     }          double fullScore = score;      double fullMax = max;      System.out.println(“Total points = ” + score + ” / ” + max);      double weightedScore = fullScore / fullMax * secondWeight;      System.out.printf(“Weighted score = %.1f / ” + secondWeight, weightedScore);      System.out.println();      return weightedScore;      }          // prints out gpa calculator     public static void gpaCalculator(double midterm, double finalScore, double homework) {     double percentage = (midterm + finalScore + homework);     System.out.println();     System.out.printf(“Overall percentage = %.1f
“, percentage);     double gpa;     if (percentage >= 85){     gpa = 3.0;     System.out.println(“Your grade will be at least a: ” + gpa);     System.out.print(“Spectacular work!”);     } else if (85 >= percentage && percentage > 75){     gpa = 2.0;     System.out.println(“Your grade will be at least a: ” + gpa);     System.out.print(“So close!”);     } else if (75 >= percentage && percentage > 60) {     gpa = 0.7;     System.out.println(“Your grade will be at least a: ” + gpa);     System.out.print(“Better luck next time.”);     } else {     gpa = 0.0;     System.out.println(“Your grade will be at least a: ” + gpa);     System.out.print(“Uh oh!”);     }   }

Post Author: admin

x

Hi!
I'm Katherine!

Would you like to get a custom essay? How about receiving a customized one?

Check it out