Advertisement
Spocoman

Account Balance

Sep 14th, 2023
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string input;
  8.     cin >> input;
  9.  
  10.     double total = 0;
  11.  
  12.     while (input != "NoMoreMoney") {
  13.         double cash = stod(input);
  14.  
  15.         if (cash < 0) {
  16.             cout << "Invalid operation!\n";
  17.             break;
  18.         }
  19.  
  20.         printf("Increase: %.2f\n", cash);
  21.         total += cash;
  22.  
  23.         cin >> input;
  24.     }
  25.    
  26.     printf("Total: %.2f\n", total);
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement