fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int pin = 0;
  6. float money = 300.0f;
  7. float deposit = 0.0f;
  8. float withdrawal = 0.0f;
  9. std::cout<<"Write pin: "<<std::endl;
  10. if(std::cin >> pin && pin == 8765)
  11. {
  12. int option = 0;
  13. do
  14. {
  15. std::cout<<"1. Deposit"<<"\n";
  16. std::cout<<"2. Withdrawal"<<"\n";
  17. std::cout<<"3. Balance"<<"\n";
  18. std::cout<<"4. Quit"<<std::endl;
  19. std::cin >> option;
  20. switch(option)
  21. {
  22. case 1:
  23. std::cout<<"Input ammount: "<<std::endl;
  24. std::cin>>deposit;
  25. money += deposit;
  26. break;
  27. case 2:
  28. std::cout<<"Quantity to withdrawal: "<<std::endl;
  29. std::cin>>withdrawal;
  30. money -= withdrawal;
  31. break;
  32. case 3:
  33. std::cout<<"Balance: "<<money<<std::endl;
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. while(std::cin.clear(), option != 4);
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0s 3476KB
stdin
8765
1
150
3
4
stdout
Write pin: 
1. Deposit
2. Withdrawal
3. Balance
4. Quit
Input ammount: 
1. Deposit
2. Withdrawal
3. Balance
4. Quit
Balance: 450
1. Deposit
2. Withdrawal
3. Balance
4. Quit