Question

In the U.S coin system, the penny is the basic coin, and it is equal to...

In the U.S coin system, the penny is the basic coin, and it is equal to cent, a nickel is equivalent to 5 cents, a dime is equivalent to 10 cents, a quarter is equivalent to 25 cents, and half-dollar is equivalent to 50 cents. Design and implement a program that would make use of the functions shown below. Each function has a single int formal parameter Amount.
a) HalfDollars (): Compute the maximum number of half-dollars that could be used in making change for Amount.
b) Quarters():Compute the maximum number of quarter that could be used in making change for Amount
c) Dimes ():Compute the maximum number of dimes that could be used in making change for Amount
d) Nickels () : Compute the maximum number of nickels that could be used in making change for Amount

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I'm assuming the argument "Amount" is in cents. Here is the code

# include <iostream>
using namespace std;

//the amount of coins that can be made in change
//is the quotient when the amount is divided
//by the coin value
//a / b in C++ computes exactly this

//if Amount is in dollars, not cents
//then simply multiply the Amount by 100
//before doing the division

int HalfDollars(int Amount) {
return Amount / 50;
}

int Quarters(int Amount) {
return Amount / 25;
}

int Dimes(int Amount) {
return Amount / 10;
}

int Nickels(int Amount) {
return Amount / 5;
}

int main() {
int n;
cout << "Enter Amount: ";
cin >> n;

cout << "Number of half-dollars " << HalfDollars(n) << endl;
cout << "Number of quarters " << Quarters(n) << endl;
cout << "Number of dimes " << Dimes(n) << endl;
cout << "Number of nickels " << Nickels(n) << endl;

return 0;
}

Here is a screenshot of some outputs:

Comment in case of any doubts.

Add a comment
Know the answer?
Add Answer to:
In the U.S coin system, the penny is the basic coin, and it is equal to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...

  • in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949)...

    in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949) - joshfor x M Inbox (4,224) - joshuar X ® AC ads/ACFrOgA6UB 1k4Z1i1xGLNQ1Lntj510 lutEUaA..pdf ECE 175: Computer Programming for Engineering Applications Lab Assignment #2 (Thursday sessions) Relevant Programming Concepts: • Branch Structure • Loop Problem 1 (15 points): Develop a C program that asks a user to enter a total change amount in cents) and outputs the change using the fewest coins. The coin...

  • All items at a "Penny Fair" are priced less than $1.00. Write a program that makes...

    All items at a "Penny Fair" are priced less than $1.00. Write a program that makes change with a minimum number of coins when a customer pays for an item with a one dollar bill. Prompt for the item price in cents, report the change due, and the number of coins of each denomination required. Use only quarters, dimes, nickels, and pennies for change (no 50 cent pieces). See sample output but your program should work for any item price....

  • C++ HW Question Your program will simulate a simple change maker for a vending machine. It...

    C++ HW Question Your program will simulate a simple change maker for a vending machine. It will start with a stock of coins and dollars. It will then repeatedly request the price for an item to be purchased or to quit. If given a price, it will accept nickels, dimes, quarters, one-dollar and five-dollar bills—deposited one at a time—in payment. When the user has deposited enough to cover the cost of the item, the program will calculate the coins to...

  • I have this code for python: num = int(input()) if num == 0: print('No change') else:...

    I have this code for python: num = int(input()) if num == 0: print('No change') else: dol = num // 100 num %= 100 Quarters = num // 25 num %= 25 Dimes = num // 10 num %= 10 Nickels = num // 5 num %= 5 Pennies = num if dol > 0: if dol == 1: print('1 Dollar') if Dollars > 1: print(dol,'Dollars') if Quarters > 0: if Quarters == 1: print('1 Quarter') if Quarters > 1:...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dolla...

    it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...

  • Write a script called makeChange that prompts the user for a monetary amount in cents less...

    Write a script called makeChange that prompts the user for a monetary amount in cents less than or equal to 99 cents (i.e. less than a loonie) and then prints how change would be made for that amount out of quarters (25-cent coins), dimes (10-cent coins), nickels (5-cent coins) and pennies (1-cent coins). The change your script specifies should be the minimum number of coins. For example, when making change for 88 cents, the result should indicate 3 quarters, 1...

  • Write a program that tells what coins to give out for as change from 1 cent...

    Write a program that tells what coins to give out for as change from 1 cent to 99 cents. Use coin denominations of 25 cents (quarters), 10 cents (dimes), and 1 cent (pennies) only. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. Solution Demo Hello I am the coin machine! I will give you the least number of coins for your change....

  • you are designing a matlab script that will function as an automated cash regisiter. the cash...

    you are designing a matlab script that will function as an automated cash regisiter. the cash register will recive two inputs,the price of an item in cents, and the amount of cents payed by the customer. the cash register will then dispense change using the highest denominations of currency available ranging from 1 dollar bill to a penny dollar = 100 cents quarter =25 cents dime= 10 cents nickel=5 penny=1 cent your program should ensure that the highest available denomiation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT