How can the program in problem be modified to output the subtotal after each value is added instead of just the final result? Include messages in the OUTPUT statements to distinguish between the subtotal and the grand total. Check the program to insure that it works correctly.
Two changes (shown in bold below) are needed:
• Add a subtotal OUTPUT statement immediately below the accumulation statement
• Modify the final OUTPUT statement to include a "grand total" message.
```
LET sum = 0
LET n = 1
DO WHILE n < = 9
LET sum = sum + n OUTPUT "The subtotal is ", sum LETn=n+ 2
LOOP
OUTPUT "The grand total is ", sum
The output would look like this:
The subtotal is 1
The subtotal is 4
The subtotal is 9
The subtotal is 16
The subtotal is 25
The grand total is 25
```
You might also like to view...
The ____ keyword indicates that the procedure can be used only within the current Code Editor window.
A. Public B. Private C. Friend D. Hidden
Display course description, total capacity and number of sections in each course, where there is more than 1 section.
What will be an ideal response?
Consider changing the if block in the frequency shift method to sourceIndex = sourceIndex - s.getLength()
What's the difference from just setting the sourceIndex to 0? This change will also reset the sourceIndex for wrapping back to the front of the sound. Is this better or worse?
If someone is ________, they are using an email message or a website to trick you into revealing your personal or financial information
A) trolling B) surfing C) phishing D) spamming