Цель этой программы - взять сумму в долларах и распечатать количество счетов, которые будут возвращены, чтобы получить эту сумму наиболее эффективно и оставшиеся изменения.(т. е. 523,33 долл. США = 50 долл. x 10/20 долл. США x 1/1 долл. США 3 / .33 осталось).Это должно работать, за исключением ошибок, которые я получаю в прикрепленном изображении.Я пробовал каждую итерацию, которой меня учили, но ничего не работает.
#include <iostream>
using namespace std;
int main()
{
double withdrawAmount; //declare variable to store use input for desired withdraw amount
do { //Ask for valid user input
cout << "Please enter an amount to withdraw from yor account" << endl;
cin >> withdrawAmount; //save user input into withdrawAmount variable
} while (withdrawAmount < 1);
//Print greatest # of bills that can be taken from the withdrawlAmount
cout << "$50 bills :"<< (int) withdrawAmount / 50 << endl;
//Print number of $50 bills
(int) withdrawAmount %= 50;
cout << "$20 bills: " << (int) (withdrawAmount %= 50) / 20 << endl;
//Print number of $20 bills
(int) withdrawAmount %= 20;
cout << "$10 bills: " << (int) (withdrawAmount %= 20) / 10 << endl;
//Print number of $10 bills
(int)withdrawAmount %= 10;
cout << "$5 bills: " << (int) (withdrawAmount %= 10) / 5 << endl;
//Print number of $5 bills
(int)withdrawAmount %= 5;
cout << "$1 bills: " << (int) (withdrawAmount %= 5) / 1 << endl;
//Print number of $1 bills
(int) withdrawAmount %= 1;
cout << "Remaining: " << withdrawAmount / 1 << endl;
return 0;
}
![enter image description here](https://i.stack.imgur.com/WeEHE.png)