Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

modfiy this program with a switch statement to display the letter grade only A,B,C,D,F no +/-. Do not use an If statement. Use Java. 2

modfiy this program with a "switch" statement to display the letter grade only A,B,C,D,F no +/-. Do not use an If statement. Use Java.

2 import java.util.Scanner; 3 4 public class GradingSystem { 5 public static void main(String[] args) { 6 7 double grade1, grade2, grade3, grade4, grade5; 8 9 double pAssignWeight = .10; 10 double hAssignWeight = .15; 11 double labsWeight = .05; 12 double quizWeight = .10; 13 double rWeight = .10; 14 double exam1Weight = .05; 15 double exam2Weight = .10; 16 double exam3Weight = .15; 17 double exam4Weight = .20; 18 double hAssign,pAssign; 19 double labs, quiz, reading; 20 double exam1, exam2, exam3, exam4; 21 double total; 22 23 24 Scanner scan = new Scanner(System.in); 25 26 System.out.println("Grades for Programming Assignments: "); 27 grade1 = scan.nextDouble(); 28 grade2 = scan.nextDouble(); 29 grade3 = scan.nextDouble(); 30 grade4 = scan.nextDouble(); 31 grade5 = scan.nextDouble(); 32 33 pAssign = (grade1 + grade2 + grade3 + grade4 + grade5)/5 ; 34 35 System.out.print("Programming assignments Average : "); 36 System.out.println(pAssign); 37 38 pAssign = pAssign * pAssignWeight; 39 40 System.out.print("Programming assignments Weight : "); 41 System.out.println(pAssign); 42 43 System.out.println(" "); 44 System.out.println("Enter 5 Homework assignments: "); 45 grade1 = scan.nextDouble(); 46 grade2 = scan.nextDouble(); 47 grade3 = scan.nextDouble(); 48 grade4 = scan.nextDouble(); 49 grade5 = scan.nextDouble(); 50 51 hAssign = (grade1 + grade2 + grade3 + grade4 + grade5)/5 ; 52 53 System.out.print("Homework assignments Average : "); 54 System.out.println(hAssign); 55 56 hAssign = hAssign * hAssignWeight; 57 58 System.out.print("Homework assignments Weight : "); 59 System.out.println(hAssign); 60 61 System.out.println(" "); 62 System.out.println("Enter 5 Labs Grades: "); 63 grade1 = scan.nextDouble(); 64 grade2 = scan.nextDouble(); 65 grade3 = scan.nextDouble(); 66 grade4 = scan.nextDouble(); 67 grade5 = scan.nextDouble(); 68 69 labs = (grade1 + grade2 + grade3 + grade4 + grade5)/5 ; 70 71 System.out.print("Labs assignments Average : "); 72 System.out.println(labs); 73 74 labs = labs * labsWeight; 75 76 System.out.print("Labs assignments Weight : "); 77 System.out.println(labs); 78 79 System.out.println(" "); 80 System.out.println("Enter 5 Quiz grades: "); 81 grade1 = scan.nextDouble(); 82 grade2 = scan.nextDouble(); 83 grade3 = scan.nextDouble(); 84 grade4 = scan.nextDouble(); 85 grade5 = scan.nextDouble(); 86 87 quiz = (grade1 + grade2 + grade3 + grade4 + grade5)/5 ; 88 89 System.out.print("Quiz Average : "); 90 System.out.println(quiz); 91 92 quiz = quiz * quizWeight; 93 94 System.out.print("Quiz Weight : "); 95 System.out.println(quiz); 96 97 98 System.out.println(" "); 99 System.out.println("Homework assignments: "); 100 grade1 = scan.nextDouble(); 101 grade2 = scan.nextDouble(); 102 grade3 = scan.nextDouble(); 103 grade4 = scan.nextDouble(); 104 grade5 = scan.nextDouble(); 105 106 reading = (grade1 + grade2 + grade3 + grade4 + grade5)/5 ; 107 108 System.out.print("Reading assignments Average : "); 109 System.out.println(hAssign); 110 111 reading = reading * rWeight; 112 113 System.out.print("Reading assignments Weight : "); 114 System.out.println(reading); 115 116 System.out.println(" "); 117 System.out.println("Enter First Exam: "); 118 exam1 = scan.nextDouble(); 119 exam1 = exam1 * exam1Weight; 120 System.out.println("First Exam Wieght : "+ exam1); 121 122 System.out.println(" "); 123 System.out.println("Enter Second Exam: "); 124 exam2 = scan.nextDouble(); 125 exam2 = exam2 * exam2Weight; 126 System.out.println("Second Exam Wieght : "+ exam2); 127 128 System.out.println(" "); 129 System.out.println("Enter Third Exam: "); 130 exam3 = scan.nextDouble(); 131 exam3 = exam3 * exam3Weight; 132 System.out.println("Third Exam Wieght : "+ exam3); 133 134 System.out.println(" "); 135 System.out.println("Enter Fourth Exam: "); 136 exam4 = scan.nextDouble(); 137 exam4 = exam4 * exam4Weight; 138 System.out.println("Fourth Exam Wieght : "+ exam4); 139 } 140 } 141

image text in transcribed
94% A 73% 90% A-70% C. 87% B+ 65% D+ 83% B 60% 80%B- 60% F 77% C+

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions