SHARE
TWEET

Untitled

a guest Mar 26th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. enum denominations {
  5.     five = 0;
  6.     ten = 0;
  7.     twenty = 0;
  8.     fifty = 0;
  9. }
  10.  
  11. int main {
  12.     int changeInput;
  13.     changeInput = getInput();
  14. }
  15.  
  16. int getInput(){
  17.     int input;
  18.  
  19.     while( 1 ){ // Infinite while, loops until it gets a valid input
  20.         cout << "Enter change: ";
  21.         cin >> input;
  22.  
  23.         if( !(change % 5) && change >= 5 && change <= 95 ){ // If modulus returns 0 and variable is 5-95
  24.             return input; // returns valid input and exits getInput function
  25.         } else {
  26.             cout << "invalid input, enter a number between 0-95 in multiples of 5"; // that's not it, chief. Loops to beginning of while()
  27.         }
  28.  
  29.     }
  30.  
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top