Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4G STC o A: YY (2 MES EACH) l. The decision table below shows fines imposed for

ID: 3842130 • Letter: 4

Question

4G STC o A: YY (2 MES EACH) l. The decision table below shows fines imposed for speeding violations. Write a code segment that assigns the correct fine to type float variable fine based on the value of type int variable speed. Speed (mph) Fine 65 or less 66-70 15.00 71-75 30.00 76-80 75.00 100.00 over 80 2 The intention of the following program fragment is to display the positive integers from 1 through n, but it doesn't work. Correct the while statement so the fragment achieves the desired effect. while (i

Explanation / Answer

Answer 1:

Java Code snippet

if(speed <= 65) {
           Fine = 0;
       } else if(speed >= 66 && speed <= 70) {
           Fine = 15.00;
       } else if(speed >= 71 && speed <= 75) {
           Fine = 30.00;
       } else if(speed >= 76 && speed <= 80) {
           Fine = 75.00;
       } else {
           Fine = 100.00;
       }

Answer 2:

i = 1;

while(i <= n) {

printf("%d",n);

i = i+1;

}

printf(" ");

If we have multiple statements under while loop, we should use {}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote