Question

Enter amount due: 5.85 Enter amount tendered: 10.00 Change Number of 5 dollar bills: 0 Number...

Enter amount due: 5.85

Enter amount tendered: 10.00

Change

Number of 5 dollar bills: 0

Number of 1 dollar bills: 4

Number of quarters: 0

Number of dimes: 1

Number of nickels: 1

Number of pennies:

Write a code with C++ to out put whats above

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

/* Please read comments*/

#include <iostream>

using namespace std;

int main()
{
cout << "Enter amount due: ";
float due; //Due amount
cin>>due;
cout <<"Enter amount tendered: ";
float tendered; //tendered amount
cin>>tendered;
cout<<"Change"<<endl;
float diff = tendered-due; //diff by tendered and due amount
cout<<"Numbers of 5 dollar bills:";
int k = (int)(diff/5); //Division of 5 means total 5 dollar amount
cout<<k<<endl;;
diff = diff - (5*(k));
cout<<"Numbers of 1 dollar bills:";
k = (int)(diff/1);
cout<<k<<endl;;
diff=diff-(k);
k = diff*100;
cout<<"Numbers of quarters:";
cout<<(k/25)<<endl; //quarter means .25 dollar
k=k%25;
cout<<"Numbers of dimes:";
cout<<(k/10)<<endl; //dimes means .1 dollar
k=k%10;
cout<<"Numbers of nickels:";
cout<<(k/5)<<endl; //nickel means .05 dollar
k=k%5;
cout<<"Numbers of pennies:";
cout<<k; //peny means .01 dollar


return 0;
}


/* See the output*/

/* That's all . Thanks*/

Add a comment
Know the answer?
Add Answer to:
Enter amount due: 5.85 Enter amount tendered: 10.00 Change Number of 5 dollar bills: 0 Number...
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
  • 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:...

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

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

  • In Python 3, Implement a program that directs a cashier how to give change. The program...

    In Python 3, Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount received from the customer. Display the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return. In order to avoid roundoff errors, the program user should supply both amounts in pennies, for example 526 instead of 5.26. Enter the amount due in pennies: 828 Enter the amount received from the customer in...

  • write a PHP program makes change for a given number of cents. The program should ask...

    write a PHP program makes change for a given number of cents. The program should ask the user for the amount of cents and then output the change for specific denominations of ten dollar bills, five dollar bills, one dollar bills, quarters, dimes, nickels, and pennies. Here is a sample program output for an input of 265 cents: Change for 2 dollars and 65 cents : 0 ten dollar bills 0 five dollar bills 2 one dollar bills 2 quarters...

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

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

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

  • Due: Wednesday June 10, 2020 A travel company has many British travelers going to the US...

    Due: Wednesday June 10, 2020 A travel company has many British travelers going to the US who would like to exchange their British Pounds into American dollars. They want you to explain how the American dollar amount will translate to the number of different bills and coins. There are many different ways to split a particular dollar amount into bills and coins, but they want to have as many high denomination bills and coins as possible. Assume that the highest...

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