// calculate num_quarters num_quarters = total_cost / 25; // update total_cost total cost = (int)total_cost % 25; // calculate num_dimes num_dimes = total_cost / 10; // update total_cost total_cost = (int)total_cost % 10; // calculate num_nickels num_nickels = total cost / 5; // update total_cost total_cost = (int)total_cost % 5; // calculate num_cents num_cents = total_cost; // print desired output cout << "You used" << num_dollars <<" dollars," << num_quarters <<<" << num_nickels<<" nickels and" << num_cents <<" pennies"; return 0; quarters, << num_dimes << "dimes,

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Only one question. Explain how did it use the modulus operator % to solve the problem
d's file-LAP1.cpp - X
mjd's file-LAP1
25
26
27
28
29
30
31
32
$3
34
5
6
☆
// calculate num_quarters
num_quarters = total_cost / 25;
// update total_cost
total_cost = (int)total_cost % 25;
// calculate num_dimes
num_dimes = total_cost / 10;
tput from:
Debug
// update total_cost
total cost = (int)total_cost % 10;
// calculate num_nickels
num_nickels = total_cost / 5;
// update total_cost
total_cost = (int)total_cost % 5;
return 0;
No issues found
x64
// calculate num_cents
num_cents = total_cost;
// print desired output
cout << "You used " << num_dollars << dollars," << num_quarters << quarters, " << num_dimes << dimes, "
<< num_nickels <<nickels and" << num_cents <<" pennies";
(Global Scope)
Local Windows Debugger
| |
Ln: 48
Ch: 1
Transcribed Image Text:d's file-LAP1.cpp - X mjd's file-LAP1 25 26 27 28 29 30 31 32 $3 34 5 6 ☆ // calculate num_quarters num_quarters = total_cost / 25; // update total_cost total_cost = (int)total_cost % 25; // calculate num_dimes num_dimes = total_cost / 10; tput from: Debug // update total_cost total cost = (int)total_cost % 10; // calculate num_nickels num_nickels = total_cost / 5; // update total_cost total_cost = (int)total_cost % 5; return 0; No issues found x64 // calculate num_cents num_cents = total_cost; // print desired output cout << "You used " << num_dollars << dollars," << num_quarters << quarters, " << num_dimes << dimes, " << num_nickels <<nickels and" << num_cents <<" pennies"; (Global Scope) Local Windows Debugger | | Ln: 48 Ch: 1
File
80 %
5
6
7
8
Amjd's file-LAP1.cpp X
Amjd's file-LAP1
1
2
3
4
13
14
15
16
17
18
19
20
21
22
23
24
Edit View
Ready
▼
#include <iostream>
using namespace std;
// Driver code
int main()
{
1 0°C
Spowin
Project
Git
B Debug x64
Output
Show output from:
Build
Debug Test Analyze
// calculate num_dollars
cout<<"Enter the cost of item 2: $";
cin >> cost_item2;
cout<<"Enter the cost of item 3: $";
cin >> cost_item3;
// find total_cost
// variables declaration and initialization
float cost_item1, cost_item2, cost_item3, total_cost;
int num_dollars, num_quarters, num_dimes, num_nickels, num_cents;
// taking three inputs from user
cout<<"Enter the cost of item 1: $";
cin >> cost_iteml;
total cost = cost_iteml + cost_item2 + cost_item3;
cout << "\nThe total cost is $" << total_cost << endl;
total_cost
total_cost * 100;
(Global Scope)
num_dollars = total cost / 100;
// update total_cost
total cost = (int)total_cost % 100;
No issues found
Tools
S
Exter
Local Wi
BER
Transcribed Image Text:File 80 % 5 6 7 8 Amjd's file-LAP1.cpp X Amjd's file-LAP1 1 2 3 4 13 14 15 16 17 18 19 20 21 22 23 24 Edit View Ready ▼ #include <iostream> using namespace std; // Driver code int main() { 1 0°C Spowin Project Git B Debug x64 Output Show output from: Build Debug Test Analyze // calculate num_dollars cout<<"Enter the cost of item 2: $"; cin >> cost_item2; cout<<"Enter the cost of item 3: $"; cin >> cost_item3; // find total_cost // variables declaration and initialization float cost_item1, cost_item2, cost_item3, total_cost; int num_dollars, num_quarters, num_dimes, num_nickels, num_cents; // taking three inputs from user cout<<"Enter the cost of item 1: $"; cin >> cost_iteml; total cost = cost_iteml + cost_item2 + cost_item3; cout << "\nThe total cost is $" << total_cost << endl; total_cost total_cost * 100; (Global Scope) num_dollars = total cost / 100; // update total_cost total cost = (int)total_cost % 100; No issues found Tools S Exter Local Wi BER
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Requirement Analysis
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education