Cash Register Enter the cost of item 1: $ Enter the cost of item 2: $ Enter the cost of item 3: $ The total cost is $ You used dollars, quarters, dimes, nickels and pennies. In the above sample run, =++ To obtain , you have to multiply the by 100, cast the result to an integer, then divide the result by 100. To obtain , you have to take the remainder of the above division and divide it by 25. To obtain , you have to take the remainder of the above division and divide it by 10. To obtain , you have to take the remainder of the above division and divide it by 5. is simply the remainder of the above division. Sample code on how to do this can be found in Lab1Sample.c A sample run is as follows: Cash Register

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%
Please due in C++ If you don’t mind answer the question: How would you use the modulus operator % to solve the above problem ?
7
1/2 |
86% +
A
Cash Register
Enter the cost of item 1: $<cost_item1>
Enter the cost of item 2: $<cost_item2>
Enter the cost of item 3: $<cost_item3>
The total cost is $<total_cost>
You used <num_dollars> dollars, <num_quarters> quarters, <num_dimes> dimes,
<num_nickels> nickels and <num_cents> pennies.
In the above sample run, <total_cost>=<cost_item1>+<cost_item2>+<cost_item3>
To obtain <num_dollars>, you have to multiply the <total_cost> by 100, cast the result
to an integer, then divide the result by 100.
To obtain <num_quarters>, you have to take the remainder of the above division and
divide it by 25.
To obtain <num_dimes>, you have to take the remainder of the above division and
divide it by 10.
To obtain <num_nickels>, you have to take the remainder of the above division and
divide it by 5.
<num_pennies> is simply the remainder of the above division.
Sample code on how to do this can be found in Lab1Sample.c
A sample run is as follows:
Cash Register
JA
Y
ENG
US
Transcribed Image Text:7 1/2 | 86% + A Cash Register Enter the cost of item 1: $<cost_item1> Enter the cost of item 2: $<cost_item2> Enter the cost of item 3: $<cost_item3> The total cost is $<total_cost> You used <num_dollars> dollars, <num_quarters> quarters, <num_dimes> dimes, <num_nickels> nickels and <num_cents> pennies. In the above sample run, <total_cost>=<cost_item1>+<cost_item2>+<cost_item3> To obtain <num_dollars>, you have to multiply the <total_cost> by 100, cast the result to an integer, then divide the result by 100. To obtain <num_quarters>, you have to take the remainder of the above division and divide it by 25. To obtain <num_dimes>, you have to take the remainder of the above division and divide it by 10. To obtain <num_nickels>, you have to take the remainder of the above division and divide it by 5. <num_pennies> is simply the remainder of the above division. Sample code on how to do this can be found in Lab1Sample.c A sample run is as follows: Cash Register JA Y ENG US
Bb 39490854
2 / 2
X
n.com/5c082fb7a0cdb/39490854?X-Blackboard-S3-Bucket-learn-us-east-1-prod-flee...
86% + |
A sample run is as follows:
Cash Register
Enter the cost of item 1: $12.50
Enter the cost of item 2: $13.25
Enter the cost of item 3: $5.17
The total cost is $30.92
+
You used 30 dollars, 3 quarters, 1 dimes, 1 nickels and 2 pennies.
Be sure to document your code with the file name, your name and student number. Add
comments throughout the code where necessary.
Question
How would you use the modulus operator % to solve the above problem?
Lab Submission:
Please email your cashRegister.c and the answer to the question to:
Transcribed Image Text:Bb 39490854 2 / 2 X n.com/5c082fb7a0cdb/39490854?X-Blackboard-S3-Bucket-learn-us-east-1-prod-flee... 86% + | A sample run is as follows: Cash Register Enter the cost of item 1: $12.50 Enter the cost of item 2: $13.25 Enter the cost of item 3: $5.17 The total cost is $30.92 + You used 30 dollars, 3 quarters, 1 dimes, 1 nickels and 2 pennies. Be sure to document your code with the file name, your name and student number. Add comments throughout the code where necessary. Question How would you use the modulus operator % to solve the above problem? Lab Submission: Please email your cashRegister.c and the answer to the question to:
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr