Advertisement
Spocoman

05. Account Balance

Sep 10th, 2023
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 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 sum = 0;
  11.  
  12.     while (input != "NoMoreMoney") {
  13.         double money = stod(input);
  14.  
  15.         if (money < 0) {
  16.             cout << "Invalid operation!\n";
  17.             break;
  18.         }
  19.  
  20.         printf("Increase: %.2f\n", money);
  21.         sum += money;
  22.         cin >> input;
  23.     }
  24.  
  25.     printf("Total: %.2f\n", sum);
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement