Ask Question
22 February, 08:14

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.

+3
Answers (2)
  1. 22 February, 10:34
    0
    A C program that assigns the number of 1 dollar bills:

    int main () {

    int amtToChange = 0;

    int numberofFives = 0;

    int numberofOnes = 0;

    amtToChange = 19;

    numberofFives = amtToChange / 5;

    numberOfOnes = amtToChange % 5;

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

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

    return 0;

    }

    The single statement is numberOfOnes = amtToChange % 5
  2. 22 February, 12:12
    0
    numOnes = amountToChange % 5;

    Explanation:

    The modulus operator % returns the remainder after division.

    To get the number of dollar bills, you need to know how much remains if you divide by 5. And that is exactly what the above statement does.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields 3 fives ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers