Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class GradeCalc
  3. {
  4. public static void main(String[] args)
  5. {
  6. Scanner kb = new Scanner(System.in);
  7.  
  8. //Declare variables
  9. final double MAX = 100;
  10. final double MIN = 0;
  11. double programAssign;
  12. double labs= -1;
  13. double mpl= -1;
  14. double midterms =-1;
  15. double finalExam =-1;
  16. System.out.println("GradeCalc");
  17. System.out.println("This application calculates the letter grade in CSC110 based on user inputs");
  18. System.out.println("\tNOTE: All inputs should be in the range of 0 to 100, inclusive.");
  19. System.out.println(" ");
  20.  
  21. System.out.print("Enter Programming Assignments percentage earned: ");
  22. programAssign = kb.nextDouble();
  23. if (programAssign <= MAX && programAssign >= MIN) {
  24. System.out.print("Enter Lab Assignments percentage earned: ");
  25. labs = kb.nextDouble();
  26. }
  27. else if (programAssign > MAX || programAssign < MIN) {
  28. System.out.println("Input error: Programming assignments percentage out of range.");
  29. }
  30. if (labs <= MAX && labs >= MIN) {
  31. System.out.print("Enter MPL Homework percentage earned: ");
  32. mpl = kb.nextDouble();
  33. }
  34. else if (labs > MAX || labs < MIN) {
  35. System.out.print("Input error: Lab Assignments out of range.");
  36. }
  37. if (mpl <= MAX && mpl >= MIN) {
  38. System.out.print("Enter midterms percentage earned: ");
  39. midterms = kb.nextDouble();
  40. }
  41. else if (mpl > MAX || mpl < MIN) {
  42. System.out.print("Input error: MPL Homework percentage out of range.");
  43. }
  44. if (midterms <= MAX && midterms >= MIN) {
  45. System.out.print("\nEnter Final exam percentage earned: ");
  46. finalExam = kb.nextDouble();
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement