On c++, im trying to make a program that will repeatedly accept the input of the user unless -999 is pressed. Additionally, if the input is not divisible by 5 or 20, then I asked for it to output "must enter divisible by 5 or 20." I want this to continue being done until they enter -999 but I do not know where to put my while loop or what to put if it is not entered. I also do not know where to put the "when finished enter -999 to leave" while making it eligible for all times and not just the start. Thank you!!!
#include <iostream> using namespace std; int main(void) { int amountEntered; cout << "Please enter the amount of money you would like to dispense (must be in 20's or 5's)" << endl; cout << "when finished, enter -999 to leave" << endl; if (amountEntered == -999) { cout << "Thank you for doing business." << endl; } cin >> amountEntered; if (amountEntered % 20 == 0) { cout << amountEntered / 20 << endl; } else { if (amountEntered % 5 == 0) { cout << amountEntered / 5 << endl; } else { cout << "You must enter multiples of twenty or five only!" << endl; } } { while (amountEntered != -999); while (amountEntered % 5 == 0); else { if (amountEntered % 5 != 0) { cout << "You must enter multiples of twenty or five only!" << endl; } } while (amountEntered % 20 == 0); } if (amountEntered % 20 != 0); { cout << "You must enter a number divisible by 20 or 5!" << endl; } if (amountEntered = -999) { cout << "Thank you for doing business." << endl; } }
while-loops in your code. And anelsewithout a matchingif.