-
Notifications
You must be signed in to change notification settings - Fork 0
/
HMC0307.cpp
54 lines (39 loc) · 1.5 KB
/
HMC0307.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Programming Exercise Chapter 03, # 7.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int d1, d2;
double netBalance, payment, interestRate, avgDailyBal, interest;
cout << "Let's find the interest on your Credit Card's unpaid balance..." << endl;
cout << "Please enter the Net Balance: " << endl << "$";
cin >> netBalance;
cin.clear();
cin.ignore(200, '\n');
cout << "Please enter the Payment Amount: " << endl << "$";
cin >> payment;
cin.clear();
cin.ignore(200, '\n');
cout << "Please enter the number of days in the billing cycle: " << endl;
cin >> d1;
cin.clear();
cin.ignore(200, '\n');
cout << "Please enter the number of days the payment was made before the billing cycle: " << endl;
cin >> d2;
cin.clear();
cin.ignore(200, '\n');
cout << "Your Net Balance is: $" << netBalance << "\n Your Payment Amount is: $" << payment << "\n Your Billing Cycle is " << d1
<< " days.\n Your payment was made " << d2 << " days before the billing cycle." << endl;
avgDailyBal = (netBalance * d1 - payment * d2) / d1;
cout << "Therefore, Your Average Daily Balance is: $" << avgDailyBal << endl;
cout << "Please enter the Interest Rate per Month: " << endl;
cin >> interestRate;
cin.clear();
cin.ignore(200, '\n');
interest = avgDailyBal * interestRate;
cout << fixed << showpoint << setprecision(2) << "The Total Interest of the Account is: $" << interest << endl;
cin.clear();
cin.ignore(200, '\n');
return 0;
}