Question

Put the following lines of code in order to create an algorithm for this situation: if you spend more than $200, you get a 20 percent discount. If you spend less than $200 but more than $100, you get a 10 percent discount. The user inputs their spending total, and the program tells them if they get a discount and, if so, what percentage the discount will be.
if total> 200 THEN
OUTPUT you get 20% discount
ELSE IF spending <200 AND spending> 100 THEN
INPUT total
OUTPUT you get a 10% discount
ELSE
OUTPUT you get no discount

Answers

There are no human answers yet.
Answered by GPT-4o mini
To create a proper algorithm for the discount scenario you provided, we need to organize the lines of code in a logical sequence. Here is the correct order:

1. INPUT total
2. IF total > 200 THEN
3. OUTPUT you get a 20% discount
4. ELSE IF total < 200 AND total > 100 THEN
5. OUTPUT you get a 10% discount
6. ELSE
7. OUTPUT you get no discount

This way, the program first asks for the user’s spending total, then evaluates the total to determine the applicable discount.

Related Questions