Minimum currency calculator

This Programs calculate minimum currency in Euros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream.h>
using namespace std;

int main()
{
int amount;
char resp[256];

cout << "Enter amount: " ;
cin>>amount;
int currency[9] = {500,200,100,50,20,10,5,2,1};
int counts[9],total;

for (int i = 0; i < 9; i++)
{
counts[i] = amount / currency[i];
amount -= counts[i] * currency[i];
total=counts[i];
cout << "Billetes de " <<currency[i] << " = " <<total <<endl;
// After this it ask user do you want to calculate more (Y/N)
// If yes continue calculating if no then display the sum of previously 
// calcutated numbers and exit. Any suggestion?

}
system ("pause");
}
do {
// Ask user to enter amount
// Calculate the counts
// Display the counts
// Ask the user if they want to continue
} while( user wanted to continue );
You should also strongly consider using iostream (no .h extension) instead of iostream.h. iostream.h was depreciated a long time ago, and it may not work correctly (or at all) on some compilers.
Last edited on
Topic archived. No new replies allowed.