Leeen

Linux_cmd_lab #1

Feb 12th, 2020
300
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.  
  3. using namespace std;
  4.  
  5. double getDeposit() {
  6.  
  7. double depos;
  8. cin >> depos;
  9. cin.clear();
  10.  
  11. while (cin.get() != '\n'){
  12. cout << "Error. Try again" << endl;
  13.  
  14. getDeposit(); }
  15.  
  16. return depos;
  17. }
  18.  
  19.  
  20. double getPercent(){
  21.  
  22. double perc;
  23.  
  24. cin >> perc;
  25. cin.clear();
  26.  
  27. while (cin.get() != '\n' || perc > 1){
  28. cout << "Error. Try again" << endl;
  29.  
  30. getPercent(); }
  31.  
  32. return perc;
  33. }
  34.  
  35. double getSum(double depos, double perc){
  36. double s = depos;
  37. for(int i = 0; i < 12; i++)
  38.     s = s + s * (1 + perc);
  39. }
  40.  
  41.  
  42. int main() {
  43.  
  44. cout << "Enter value of deposit" << endl;
  45.  
  46. double depos = getDeposit();
  47.  
  48. cout << "Enter value of percent [x% * 0,01]" << endl;
  49.  
  50. double perc = getPercent();
  51.  
  52. double sum = getSum(depos, perc);
  53.  
  54. cout << "Sum = " << sum;
  55.  
  56. }
Add Comment
Please, Sign In to add comment