Putting the Steps in Order In a previous exercise on "thinking like a computer, you were given some unordered steps for a candy sale program and asked to put them in order. The problem was as follows "Chocolate truffles cost $20 per pound for the first 5 pounds, but only $12 per pound for any amount in excess of 5 pounds. How would you compute the cost, stored in a variable named total, for any given amount of truffles?" There are a few slightly different ways that the steps can be ordered. Here's one that works well for our purposes 1. Create a variable named pounds that can store an integer. 2. Create a variable named total that can store a floating-point number. 3. Record the amount of truffles in the variable named pounds 4 If pounds is five or less, go to the next step, otherwise, go to Step 7. 5. Set total to pounds times 201 6. Go to Step 10, 7. Set total to 100 8. Subtract 5 from pounds 9. Multiply pounds by 12 and add it to total 10. End. Thinking at a Higher Level If we think about these steps in terms of modules, there are really only two major activities 1. Get the amount of truffles from the user. 2. Compute how much this amount of truffles will cost this actually reveals a bit of a flaw in our steps after computing the amount, there's nothing that actually displays the results back to the user

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
from pounds!
9. Multiply pounds by 12 and add it to total.
10. End
Thinking at a Higher Level
If we think about these steps in terms of modules, there are really only two major activities:
1. Get the amount of truffles from the user.
2 Compute how much this amount of truffles will cost
This actually reveals a bit of a flaw in our steps after computing the amount, there's nothing that actually displays the results back to the user
Let's revise our high-level" view to include some output
1. Display a welcome message on the screen.
2. Get the amount of truffles from the user.
1.Compute how much this amount of truffles will cost
4 Display the results on the screen.
In the pages that follow, we'l create some output modules in C/C to take care of Steps 1 and 4, then create a professing module for Step-1, and finally return to create an input
module for Step 2. This may seem "out of order, but we'll build up some concepts step-by-step, Just because our program needs to do things in a particular order, that doesn't mean
we need to develop our modules in that same order. We'll make sure they get used in right order by main, our controller module
Let's get started
Next Output Modudes
Let's Write a Candy Sale Program Contents
El
#
B
911F
MMA
Transcribed Image Text:from pounds! 9. Multiply pounds by 12 and add it to total. 10. End Thinking at a Higher Level If we think about these steps in terms of modules, there are really only two major activities: 1. Get the amount of truffles from the user. 2 Compute how much this amount of truffles will cost This actually reveals a bit of a flaw in our steps after computing the amount, there's nothing that actually displays the results back to the user Let's revise our high-level" view to include some output 1. Display a welcome message on the screen. 2. Get the amount of truffles from the user. 1.Compute how much this amount of truffles will cost 4 Display the results on the screen. In the pages that follow, we'l create some output modules in C/C to take care of Steps 1 and 4, then create a professing module for Step-1, and finally return to create an input module for Step 2. This may seem "out of order, but we'll build up some concepts step-by-step, Just because our program needs to do things in a particular order, that doesn't mean we need to develop our modules in that same order. We'll make sure they get used in right order by main, our controller module Let's get started Next Output Modudes Let's Write a Candy Sale Program Contents El # B 911F MMA
18
Candy Sale Algorithm
Putting the Steps in Order
In a previous exercise on "thinking like a computer, you were given some unordered steps for a candy sale program and asked to put them in order. The problem was as follows:
"Chocolate truffles cost $20 per pound for the first 5 pounds, but only $12 per pound for any amount in excess of 5 pounds. How would you compute the cost, stored in a variable
named total, for any given amount of truffles?
There are a few slightly different ways that the steps can be ordered. Here's one that works well for our purposes
1. Create a variable named pounds that can store an integer.
2. Create a variable named total that can store a floating-point number.
3. Record the amount of truffles in the variable named pounds.
4. If pounds is five or less, go to the next step, otherwise, go to Step 7.
5. Set total to pounds times 20
6. Go to Step 10,
7. Set total to 100
8. Subtract 5 from pounds
9. Multiply pounds by 12 and add it to total.
10. End
Thinking at a Higher Level
If we think about these steps in terms of modules, there are really only two major activities
1. Get the amount of truffies from the user,
2. Compute how much this amount of truffles will cost
this actually reveals a bit of a flaw in our steps after computing the amount, there's nothing that actually displays the results back to the user
Type hele to search
O
121
V
939
1864
1224ANR
Mar
Transcribed Image Text:18 Candy Sale Algorithm Putting the Steps in Order In a previous exercise on "thinking like a computer, you were given some unordered steps for a candy sale program and asked to put them in order. The problem was as follows: "Chocolate truffles cost $20 per pound for the first 5 pounds, but only $12 per pound for any amount in excess of 5 pounds. How would you compute the cost, stored in a variable named total, for any given amount of truffles? There are a few slightly different ways that the steps can be ordered. Here's one that works well for our purposes 1. Create a variable named pounds that can store an integer. 2. Create a variable named total that can store a floating-point number. 3. Record the amount of truffles in the variable named pounds. 4. If pounds is five or less, go to the next step, otherwise, go to Step 7. 5. Set total to pounds times 20 6. Go to Step 10, 7. Set total to 100 8. Subtract 5 from pounds 9. Multiply pounds by 12 and add it to total. 10. End Thinking at a Higher Level If we think about these steps in terms of modules, there are really only two major activities 1. Get the amount of truffies from the user, 2. Compute how much this amount of truffles will cost this actually reveals a bit of a flaw in our steps after computing the amount, there's nothing that actually displays the results back to the user Type hele to search O 121 V 939 1864 1224ANR Mar
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY