MHB How to Efficiently Distribute Change Using Five and One Dollar Bills

  • Thread starter Thread starter moodtl32
  • Start date Start date
  • Tags Tags
    Change
moodtl32
Messages
2
Reaction score
0
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 Input Goes Here/

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

return 0;
}

my input was amountToChange = numOnes % 5;

Which is incorrect.
 
Physics news on Phys.org
moodtl32 said:
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 Input Goes Here/

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

return 0;
}

my input was amountToChange = numOnes % 5;

Which is incorrect.
FOUND THE ANSWER

numOnes = amountToChange % 5;
 
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Back
Top