aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-19 14:56:32 -0700
committerWiserJ <[email protected]>2021-10-19 14:56:32 -0700
commitc91dac99de1e1fefc9a82d6994fe4bed378d20a1 (patch)
tree37e0431ee67f263716d382dfd342071de70661d8
parentc (diff)
downloadcst116-lab3-jeffwoit-c91dac99de1e1fefc9a82d6994fe4bed378d20a1.tar.xz
cst116-lab3-jeffwoit-c91dac99de1e1fefc9a82d6994fe4bed378d20a1.zip
p.177
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp
index 5e5a35b..c5a7f67 100644
--- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp
+++ b/CST116F2021-Lab3/CST116F2021-Lab3.cpp
@@ -7,6 +7,41 @@ using namespace std;
int main()
{
+ //p.177 8.2
+
+ int input = 0;
+ int remainder = 0;
+
+ cout << "Please enter an integer between 1 and 50: ";
+ cin >> input;
+
+ if (input < 1 || input > 50)
+ {
+ cout << "User input invalid. Exiting program.";
+ return -1;
+ }
+
+ remainder = input % 2;
+
+ while (remainder !=0)
+ {
+ input = input--;
+ remainder = input % 2;
+ }
+
+ while (input != 0)
+ {
+ cout << input << ' ';
+ input = input - 2;
+ }
+
+ cout << "0.";
+
+ return 0;
+
+
+
+
//p.168
//1. Take a loan within the correct bounds and calculate the interest and fees.
//2. Program takes 2 inputs, loan and interest rate. Loan can only be between 100 and 1000 dollars and between 1 and 18% interest rate. Display an error otherwise and end the program. Determine loan fees based on the loan amount. Calculate the interest and display loan, interest rate, and sum of the interest and fees.
@@ -20,7 +55,7 @@ int main()
5. Calculate the interest on the loan.
6. Print Loan, Interest Rate, and the sum of the interest and fees.*/
- float loan = 0;
+ /*float loan = 0;
float rate = 0;
float interest = 0;
int fees = 0;
@@ -64,7 +99,7 @@ int main()
cout << "\nYou have chosen a loan of $" << loan << " at an interest rate of " << rate << "%.\n";
cout << "Your interest and fees come to a total of $" << sum << ".\n";
- return 0;
+ return 0;*/