Question

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

it c++ coding. please write on atom software.

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

#include<iostream>
using namespace std;
int main()
{
int money, c_money, quarters, dimes, nickels, pennies, remainder; char response;
new_input:
   const int QUARTER =25,DIME=10,NICKEL=5;
  
   cout<<"Change Calculator\n---------------------\n";
cout << " Enter dollar amount (as an integer): $";
cin >> money;
while (money < 0)
{   
cout << " Invalid input , please enter a non-negative value " << endl;
cin >> money;
}
c_money = money;
quarters = (int)c_money / QUARTER;
remainder = (int)c_money % QUARTER;
dimes = (int)remainder / DIME;
remainder = (int)remainder % DIME;
nickels = (int)remainder /NICKEL;
remainder = (int)remainder % NICKEL;
pennies = (int)remainder ;
cout << endl;
cout << " The equivalent in coins : " << endl;
cout << quarters << " Quarters"<<endl;
cout <<dimes <<" Dimes"<< endl;
cout <<nickels <<" Nickels"<< endl;
cout << pennies << " Pennies"<<endl<<endl;
cout << "Do you want to enter more values ?? type , y or n and press Enter ! " << endl;
cin >> response;
if (response == 'y')
{
goto new_input;
}
else { cout << " Thanks for using our app !! " << endl << endl; }
return 0;
}

output:

Change Calculator
---------------------
Enter dollar amount (as an integer): $534

The equivalent in coins :
21 Quarters
0 Dimes
1 Nickels
4 Pennies

Do you want to enter more values ?? type , y or n and press Enter !
y
Change Calculator
---------------------
Enter dollar amount (as an integer): $100

The equivalent in coins :
4 Quarters
0 Dimes
0 Nickels
0 Pennies

Do you want to enter more values ?? type , y or n and press Enter !
n
Thanks for using our app !!

Process exited normally.
Press any key to continue . . .

Add a comment
Know the answer?
Add Answer to:
it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dolla...
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...

  • Write a program with total change amount as an integer input, and output the change using...

    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 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes

  • Write a class encapsulation the concept of coins (Coins java), assuming that coins have the following...

    Write a class encapsulation the concept of coins (Coins java), assuming that coins have the following attributes: a number of quarters, a number of dims, a number of nickels, and a number of pennies. Include a constructor (accept 4 numbers that represent the number of coins for each coin type), mutator and accessot methods, and method tostring. The tostring method should return a string in the following format: Total Value: $5.50 10 quarters, 20 dimes, 19 nickels, and 5 pennies...

  • C Program that prompts the user to enter a number that represents a pile of pennies....

    C Program that prompts the user to enter a number that represents a pile of pennies. Then, the program should use that input value to distribute the cents over monetary denominations of dollars, half dollars, quarters, dimes, nickels and pennies. Distribute the pennies over the other denominations with Change function :    prototype: void Change(int *dollars, int *halfDollars, int *quarters, int *dimes, int *nickels, int *pennies); The function takes a logical input value via its pennies parameter that represents the total...

  • Construct a program in C++ that exchanges coins for cash like Coinstar that is located in...

    Construct a program in C++ that exchanges coins for cash like Coinstar that is located in several grocery stores. You will prompt the user to provide you with the total number of pennies, nickels, dimes, and quarters, respectively.   You are to determine the total amount of money entered by the user and then output the cash that should be received. For example, if a user enters 50 pennies, 10 dimes, 10 nickels, and 5 quarters, then the user would receive...

  • Write a C program that calculates exact change. In order to receive full credit, please remember...

    Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...

  • Given a value V in cents, you need to make change using a minimum number of...

    Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply of quarters, nickels, dimes, and pennies. Find the minimum number of coins. Display the quantity of each coin and the total number of coins, similar to the example output below. Use global constant identifiers, of type unsigned int, for the values of quarters, nickels, dimes, and pennies. Example: const unsigned int QUARTER = 25: Do not use...

  • C++ Write a program that helps a young student learn to make change. Use the random...

    C++ Write a program that helps a young student learn to make change. Use the random number generator to generate change amounts between1¢ and 99¢. Ask the user how many quarters, dimes, nickels and pennies they need to make that amount. Determine whether the coins specified by the user total the specified amount and give them feedback on their answer including whether they used the minimum or optimum number of coins to produce the amount. Sample output of a program...

  • Write a program called "ConvertPennies" to input an integer value representing a number of pennies and...

    Write a program called "ConvertPennies" to input an integer value representing a number of pennies and convert it to its equivalent number of Dollars, Quarters, Dimes, Nickels and Pennies. Following is the result of the execution of this program for 292 pennies. Enter the amount of pennies to convert: 292 pennies is equal to 2 one dollar bills 3 quarters 1 dimes 1 nickels 2 pennies Have a nice day! This is given: //********************************************************************** // Programmer: Your first and last...

  • implement a class called PiggyBank that will be used to represent a collection of coins. Functionality...

    implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...

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