-
Notifications
You must be signed in to change notification settings - Fork 0
/
hmw_3_1.cpp
37 lines (27 loc) · 975 Bytes
/
hmw_3_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Homework 3_1
Arian Owji
604649619
*/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double future_balance (double init_balance, double rate, double year) {
double future_balance = init_balance * pow((1 + (rate * .01)), year);
return future_balance;
}
int main()
{
double init_balance;
double rate;
std::cout << "Enter the initial balance: ";
std::cin >> init_balance;
std::cout << "Enter the interest rate in percent: ";
std::cin >> rate;
std::cout << endl;
std::cout << "After 10 years, the balance is $" << fixed << setprecision(2) << future_balance (init_balance, rate, 10) << endl;
std::cout << "After 20 years, the balance is $" << fixed << setprecision(2) << future_balance (init_balance, rate, 20) << endl;
std::cout << "After 30 years, the balance is $" << fixed << setprecision(2) << future_balance (init_balance, rate, 30) << endl << endl;
return 0;
}