-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_ifElseDEMO.cpp
More file actions
51 lines (40 loc) · 1.44 KB
/
Copy pathif_ifElseDEMO.cpp
File metadata and controls
51 lines (40 loc) · 1.44 KB
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
//************************************************************************
// Author: Rolando Carreon
// Date: jan 28 2025
// Language: C++
// Assignment: If_If/ElseDEMO
// Description: get credit card balence and payment from the user
// and calculate interests and displa account details.
//************************************************************************
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
// declare local variables
double creditCardBalance;
double payment;
double interest = 0.0;
const double INTEREST_RATE = .015;
// setup the output formatting for currency //
cout << fixed << showpoint << setprecision(2);
// get the balance and pament from the user //
cout << "Enter the credit card balance: ";
cin >> creditCardBalance;
// prompt for payment //
cout << "Enter the payment amount: ";
cin >> payment;
// calculate the new balance //
creditCardBalance -= payment;
// if there's a balance amount, calculate the interest //
if(creditCardBalance > 0)
{
interest = creditCardBalance * INTEREST_RATE;
}
// display the account details //
cout << "The new creditCardBalance is: $" << creditCardBalance << endl;
cout << "The interest to be added to your account is: $"
<< interest << endl;
cout << "Next month's bill is: $" << creditCardBalance + interest << endl;
return 0;
}