Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GradeCalc
- {
- public static void main(String[] args)
- {
- Scanner kb = new Scanner(System.in);
- //Declare variables
- final double MAX = 100;
- final double MIN = 0;
- double programAssign;
- double labs= -1;
- double mpl= -1;
- double midterms =-1;
- double finalExam =-1;
- System.out.println("GradeCalc");
- System.out.println("This application calculates the letter grade in CSC110 based on user inputs");
- System.out.println("\tNOTE: All inputs should be in the range of 0 to 100, inclusive.");
- System.out.println(" ");
- System.out.print("Enter Programming Assignments percentage earned: ");
- programAssign = kb.nextDouble();
- if (programAssign <= MAX && programAssign >= MIN) {
- System.out.print("Enter Lab Assignments percentage earned: ");
- labs = kb.nextDouble();
- }
- else if (programAssign > MAX || programAssign < MIN) {
- System.out.println("Input error: Programming assignments percentage out of range.");
- }
- if (labs <= MAX && labs >= MIN) {
- System.out.print("Enter MPL Homework percentage earned: ");
- mpl = kb.nextDouble();
- }
- else if (labs > MAX || labs < MIN) {
- System.out.print("Input error: Lab Assignments out of range.");
- }
- if (mpl <= MAX && mpl >= MIN) {
- System.out.print("Enter midterms percentage earned: ");
- midterms = kb.nextDouble();
- }
- else if (mpl > MAX || mpl < MIN) {
- System.out.print("Input error: MPL Homework percentage out of range.");
- }
- if (midterms <= MAX && midterms >= MIN) {
- System.out.print("\nEnter Final exam percentage earned: ");
- finalExam = kb.nextDouble();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement