Java - Statement Grading System

Description

Grading System

Demo

import java.util.Scanner;

public class GradingSystem {

  public static void main(String args[]) {
    double score1;
    double score2;
    double score3;
    double final1;
    double attendance;
    double hmwk;// ww w. j a va2  s .  c  om

    Scanner keyboard = new Scanner(System.in);
    System.out.println("Test Score 1");
    score1 = keyboard.nextDouble();

    System.out.println("Test Score 2");
    score2 = keyboard.nextDouble();

    System.out.println("Test Score 3");
    score3 = keyboard.nextDouble();

    System.out.println("Final Test");
    final1 = keyboard.nextDouble();
    keyboard.close();

    double averageScore = ((score1 + score2 + score3) / 3);

    System.out.println("Attendance grade");
    attendance = keyboard.nextDouble();

    System.out.println("Homework grade");
    hmwk = keyboard.nextDouble();

    double finalGrade = (averageScore * .5 + final1 * .25 + attendance * .1 + hmwk * .15);

    System.out.println(finalGrade);

    if (0 <= finalGrade && finalGrade <= 64) {
      System.out.println("F");
    }
    else if (65 <= finalGrade && finalGrade <= 70) {
      System.out.println("D");
    }
    else if (71 <= finalGrade && finalGrade <= 80) {
      System.out.println("C");
    }
    else if (81 <= finalGrade && finalGrade <= 90) {
      System.out.println("B");
    }
    else if (91 <= finalGrade && finalGrade <= 100) {
      System.out.println("A");
    }
  }
}

Related Topic