Loops and Decisions Assignment

profilejpFlute

Explain the difference between:

s = 0;

If (x > 0) s++;

If (y > 0) s++;

and

s = 0;

if (x > 0) s++;

else if (y > 0) s++;

Part B

What are the values of s and n after the following loops?:

a. int s = 1;

    int n = 1;

    while (x < 10) 

    s = s + n;

    n++;

b. int s = 1;

    int n;

    for (n = 1; n < 5; n++)

        s = s + n;

c. int s = 1;

    int n = 1;

    do

    {

        s = s + n;

        n++;

    }

    while (s < 10 * n);

Part C

Write a program that accepts four grades, calculates the average of the four grades, and then converts the average from a number grade into a letter grading using the following grading scale: 

A 100 - 90

B  89 - 80

C  79 - 70

D  69 - 60

F  59 - 0

Output the final grade average along with the letter grade

Submit a screenshot of the executed program and the code of the program.

    • 8 years ago
    • 20
    Answer(3)

    Purchase the answer to view it

    blurred-text
    • attachment
      loops_and_decisions_assignment.docx

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      loops_and_decisions_assignment.docx

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      loops_and_decisions_assignment.docx