Write a program that ask the user to enter TL amount and then shows how to pay that amount using the smallest number of 200TL, 100TL,50TL,20TL,10TL,AND5TL bills:
enter an lira amount: 360
200TL bills:1
100TL bills:1
50TL bills:1
20TL bills:0
10TL bills:1
5TL bills: 0
HINT:Divide the amount by 20 to determine the number of 20TL bills needed, and then reduce the amount by the total value of the 20TL bills. Repeat for the other bill sizes. Be sure to use integers values throught, not floating-point numbers.
1
Expert's answer
2012-10-11T08:29:59-0400
#include <iostream> #include <iomanip> using namespace std;
int main() { int amount; int count[6]; int bills[6] = { 200, 100, 50, 20, 10, 5 }; for (int i = 0; i < 6; i++) & count[i] = 0; cout << "Enter an lira amount: "; cin >> amount; cout << endl; for (int i = 0; i < 6; i++) { & count[i] = amount / bills[i]; & amount = amount % bills[i]; & cout << setw(4) << bills[i] << "TL" << " bills: " << count[i] << endl; }
Comments
Leave a comment