exerciseFeb1808

exerciseFeb1808 - COMP202 Instructor: Ladan Mahabadi...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP202 Instructor: Ladan Mahabadi February 18, 2008 Professor Absem’s Grading: It is the end of term and Professor Absem needs to compile grades for his students. Each student’s final grade can be only one of: A+: > 90 A: 85 – 90 A-: 80 – 84.9 B+: 75 – 79.9 B: 70 – 74.9 B-: 65 – 69.9 C+: 60 – 64.9 C: 55 – 59.9 C-: 50 – 54.9 F: < 49.9 Write a program that allows the professor to enter 5 numerical values (corresponding to three projects, a midterm and a final exam) and outputs the corresponding letter grade. The five entered grades consist of grades for three projects (worth %30 of the final grade), a midterm exam (%20 of the final grade) and a final exam (worth %50 of the final grade).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
import java.util.Scanner; public class Grading {   enum Grade {AP, A, AM, BP, B, BM, CP, C, CM, F}      public static void main (String[] args)   {     /**      * Three projects are worth %30      * Midterm is worth %20      * Final exam is worth %50 of the final grade      * */     Scanner scan = new Scanner(System.in);     double result = 0.0;     Grade finalGrade = Grade.F;          for (int i = 0; i < 3; i++)     {       System.out.println("Project " + (i+1) + " grade:");       result += scan.nextDouble();     }        result *= 0.30;          System.out.println("Midterm grade: ");     result += scan.nextDouble() * 0.20;          System.out.println("Final exam grade: ");     result += scan.nextDouble() * 0.50;          if (result >= 90)       finalGrade = Grade.AP;            finalGrade = Grade.A;     
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

exerciseFeb1808 - COMP202 Instructor: Ladan Mahabadi...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online