Advertisement
JennyMcJenster

Standard | Simple Dosh Adder

Sep 7th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     char endstate = 0;
  7.     int lv = 0;
  8.     int total = 0;
  9.  
  10.     cout << "Enter amount in coins, then hit Return to add to total." << endl
  11.          << "Enter a negative number to subtract it from the total." << endl
  12.          << "Enter '0' once to check running total." << endl
  13.          << "Enter '0' again to end program." << endl<<endl;
  14.  
  15.     while( endstate != 2 )
  16.     {
  17.         cin >> lv;
  18.         if( lv == 0 )
  19.         {
  20.             if( endstate == 1 )
  21.                 endstate = 2;
  22.             else
  23.             {
  24.                 endstate = 1;
  25.                 int totalcoins = abs( ((float)total/100 - total/100)*100 );
  26.                 cout << "Total: " << total/100 << "." << (totalcoins<10?"0":"") << totalcoins << endl;
  27.             }
  28.         }
  29.         else
  30.         {
  31.             if( endstate != 0 ) endstate = 0;
  32.             total += lv;
  33.         }
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement