Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double getDeposit() {
- double depos;
- cin >> depos;
- cin.clear();
- while (cin.get() != '\n'){
- cout << "Error. Try again" << endl;
- getDeposit(); }
- return depos;
- }
- double getPercent(){
- double perc;
- cin >> perc;
- cin.clear();
- while (cin.get() != '\n' || perc > 1){
- cout << "Error. Try again" << endl;
- getPercent(); }
- return perc;
- }
- double getSum(double depos, double perc){
- double s = depos;
- for(int i = 0; i < 12; i++)
- s = s + s * (1 + perc);
- }
- int main() {
- cout << "Enter value of deposit" << endl;
- double depos = getDeposit();
- cout << "Enter value of percent [x% * 0,01]" << endl;
- double perc = getPercent();
- double sum = getSum(depos, perc);
- cout << "Sum = " << sum;
- }
Add Comment
Please, Sign In to add comment