Ask Question
10 September, 17:07

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. 10 September, 17:20
    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. 10 September, 18:54
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers