-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifStatements.cpp
94 lines (68 loc) · 1.86 KB
/
ifStatements.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Chapter 04 , programming challenge 12, this program will calculate and display the bank's
// service fees for the month
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Constants
const double CHECK = 10;
const double EXTRA = 15;
// Declare Variables
int checks;
double checkFee;
double balance;
double total;
// Get the balance and the number of checks written
cout << "Beginning balance: ";
cin >> balance;
cout << "Number of checks written: ";
cin >> checks;
// Conditions
if (balance > 400)
{
if (checks < 0)
cout << "Invalid number of checks.";
else if (checks < 21)
checkFee = CHECK + (0.1 * checks);
else if (checks > 20 && checks < 40)
checkFee = CHECK + (0.08 * checks);
else if (checks > 39 && checks < 60)
checkFee = CHECK + (0.06 * checks);
else if (checks > 59)
checkFee = CHECK + (0.04 * checks);
total = checkFee;
}
else if (balance < 0)
{
if (checks < 0)
cout << "Invalid number of checks.";
else if (checks < 21)
checkFee = CHECK + (0.1 * checks);
else if (checks > 20 && checks < 40)
checkFee = CHECK + (0.08 * checks);
else if (checks > 39 && checks < 60)
checkFee = CHECK + (0.06 * checks);
else if (checks > 59)
checkFee = CHECK + (0.04 * checks);
total = checkFee;
cout << "The account is overdrawn!" << endl;
}
else if (balance < 400)
{
if (checks < 0)
cout << "Invalid number of checks.";
else if (checks < 21)
checkFee = CHECK + (0.1 * checks);
else if (checks > 20 && checks < 40)
checkFee = CHECK + (0.08 * checks);
else if (checks > 39 && checks < 60)
checkFee = CHECK + (0.06 * checks);
else if (checks > 59)
checkFee = CHECK + (0.04 * checks);
total = checkFee + EXTRA;
}
// Display the monthly fees
cout << "The bank fee this month is: " << fixed << showpoint << setprecision(2) << total << endl;
return 0;
}