/* Write a program that asks user to input an amount of money from 0.00-10.00 € (decimals are allowed). Program must then determine what is the amount of 20c, 10c, 5c and 1c coins from which the given amount is formed. Program must print number of each coins needed, and total amount of them. Number of coins must always be minimum */ #include #include #include using namespace std; int main(void) { float rahat, rahat2; int XXs=0, Xs=0, VIs=0, Is=0; cout << "Anna rahamaara (0.00 - 10.00 euroa): "; cin >> rahat; rahat2 = rahat; while (true){ if(rahat >= 0.2){ rahat -= 0.2; XXs++; }else if(rahat >= 0.1){ rahat -= 0.1; Xs++; }else if(rahat >= 0.05){ rahat -= 0.05; VIs++; }else if((rahat < 0.05) && (rahat > 0)){ rahat -= 0.01; Is++; }else{ break; } } cout << "Antamasi rahamaara oli " << rahat2 << " euroa. Rahat 20c, 10c, 5c, ja 1c kolikkoina:" << endl; cout << "20c " << XXs << " kpl" << endl; cout << "10c " << Xs << " kpl" << endl; cout << "5c " << VIs << " kpl" << endl; cout << "1c " << Is << " kpl" << endl; system("PAUSE"); return 0; }