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...

  • 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...

  • I made this C program to count change and make a slip saying the exact dollar...

    I made this C program to count change and make a slip saying the exact dollar and change amount given. every time I run the program it says the change given is 477256577 and i'm not sure what I have done wrong? #include<stdio.h> int main(void) { char first, last; int pennies; int nickels; int dimes; int quarters; int loonies; int change; int t_dollars; int t_cents; printf("Type in your 2 initials and press return> "); scanf("%c%c",&first,&last); printf("%c%c please enter in your...

  • Write a program called CountCoins.java that prompts the user for the input file name (you can...

    Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...

  • Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number...

    Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two constructors (non-argument constructor that assigns 1 to each coin, and another constructor that takes necessary arguments to create an object), needed getter and setter methods, method toString (to print coins objects in a meaningful way), and method equals (to compare two coins objects based on number of coins). Also include...

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