// 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,

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 6RQ
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT