aboutsummaryrefslogtreecommitdiff
path: root/5c/knox7.10 2/knox7.10 2.cpp
diff options
context:
space:
mode:
Diffstat (limited to '5c/knox7.10 2/knox7.10 2.cpp')
-rw-r--r--5c/knox7.10 2/knox7.10 2.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/5c/knox7.10 2/knox7.10 2.cpp b/5c/knox7.10 2/knox7.10 2.cpp
new file mode 100644
index 0000000..5898aff
--- /dev/null
+++ b/5c/knox7.10 2/knox7.10 2.cpp
@@ -0,0 +1,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;
+}