Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- char endstate = 0;
- int lv = 0;
- int total = 0;
- cout << "Enter amount in coins, then hit Return to add to total." << endl
- << "Enter a negative number to subtract it from the total." << endl
- << "Enter '0' once to check running total." << endl
- << "Enter '0' again to end program." << endl<<endl;
- while( endstate != 2 )
- {
- cin >> lv;
- if( lv == 0 )
- {
- if( endstate == 1 )
- endstate = 2;
- else
- {
- endstate = 1;
- int totalcoins = abs( ((float)total/100 - total/100)*100 );
- cout << "Total: " << total/100 << "." << (totalcoins<10?"0":"") << totalcoins << endl;
- }
- }
- else
- {
- if( endstate != 0 ) endstate = 0;
- total += lv;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement