Answer to Question #217713 in C++ for Kuzi

Question #217713
A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields 3 fives and 4 ones. Write a single statement that assigns the number of 1 dollar bills to variable numOnes, given amountToChange. Hint: Use the % operator.

#include <iostream>
using namespace std;
int main() {
int amountToChange;
int numFives;
int numOnes;

cin >> amountToChange;
numFives = amountToChange / 5;

/* Your solution goes here */

cout << "numFives: " << numFives << endl;
cout << "numOnes: " << numOnes << endl;
return 0;
}
1
Expert's answer
2021-07-17T01:30:49-0400
#include <iostream>


using namespace std;


int main() {


int amountToChange;


int numFives;


int numOnes;


cin >> amountToChange;


numFives = amountToChange / 5;


/* Your solution goes here */
numOnes = amountToChange % 5;


cout << "numFives: " << numFives << endl;


cout << "numOnes: " << numOnes << endl;


return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

William Sides
19.01.23, 01:17

Thank you!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS