blob: 5898aff9f1eea778bc6a62b11c18327b9a3ed430 (
plain) (
blame)
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
|
// knox7.10 2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
using namespace std;
int main()
{
double intrest, amount, fee, intrestRate;
cout << "\t-Loan Calculator-\n\n";
cout << "Input the requested amount in dollars: ";
cin >> amount;
cout << "\nInput the intrest rate in percent: ";
cin >> intrestRate;
cout.precision(2);
if (100 > amount || amount > 1000) {
cout << fixed << "The amount of the loan must be between $100 and $1000. You input $" << amount << ".";
return 1;
}
if (1 > intrestRate || intrestRate > 18) {
cout << "The intrest rate of the loan must be between 1% and 18%. You input " << intrestRate << "%.";
return 1;
}
if (amount <= 500) {
fee = 20;
}
else {
fee = 25;
}
intrest = amount * (intrestRate / 100);
cout << fixed << "\n\nYou requested a loan for $" << amount << ".\n";
cout.precision(0);
cout << "The intrest rate is " << intrestRate << "%.\n";
cout.precision(2);
cout << fixed << "The intrest is $" << intrest << ", and the fees are $" << fee << ", for a total of: $" << fee + intrest << ".";
return 0;
}
|