Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. (TCO 5) Write a function that converts an input of some integer number of nic

ID: 642255 • Letter: 3

Question

3. (TCO 5) Write a function that converts an input of some integer number of nickels into outputs of integer numbers of dollars, quarters, and nickels. Do not write a main function. Your function does not do cin or cout. Your function will have four parameters. Make sure you use appropriate parameter passing techniques! Your function will be a void function. There are 5 nickels in a quarter, and 20 nickels in a dollar. For example, if the total number of nickels input is 27, the results are 1 dollar, 1 quarter, and 2 nickels. (Points : 15)

Explanation / Answer

#include <iostream>

using namespace std;

void calMoney(int n)
{
   int d, q, i, r;

     d = n / 20;
     r = n % 20;

     q = r / 5;
     i = r % 5;

     cout << d << " dollars, " << q << " quaters and " << i << " nickels";
}

int main()
{
   calMoney(27);
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote