aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp')
-rw-r--r--CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp326
1 files changed, 326 insertions, 0 deletions
diff --git a/CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp b/CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp
new file mode 100644
index 0000000..dc999dc
--- /dev/null
+++ b/CST116F2021-Lab3/CST116 Lab3 Harris-Toovy.cpp
@@ -0,0 +1,326 @@
+//Code by Jordan Harris-Toovy for OIT's CST116 course. October 2021
+
+#include <iostream>
+#include <iomanip>
+using namespace std;
+
+//7.2 - Learn by doing exercises #1
+
+/*
+int main()
+{
+ float money = 0.0F;
+ bool has_checkings = 0;
+ bool has_savings = 0;
+
+ cout << "Please enter the amout of money you have (in USD): \n";
+ cin >> money;
+
+ cout << "Do you have a checkings account (enter 0 for no, 1 for yes): \n";
+ cin >> has_checkings;
+
+ cout << "Do you have a savings account (enter 0 for no, 1 for yes): \n";
+ cin >> has_savings;
+
+ cout << "\n\n";
+ cout << "Your account type is: ";
+
+ if (money >= 25000)
+ cout << "Platnum" << endl;
+ else if (money >= 10000)
+ {
+ if (has_checkings == 1 && has_savings == 1)
+ cout << "Gold" << endl;
+ else if ((has_checkings == 1 && has_savings == 0) || (has_checkings == 0 && has_savings == 1))
+ cout << "Silver" << endl;
+ else
+ {
+ cout << "Error" << endl;
+ return 1;
+ }
+ }
+ else
+ cout << "Copper" << endl;
+
+ return 0;
+}
+*/
+
+//7.4 - Learn by doing exercises #1
+
+/*
+int main()
+{
+ cout << "Student Grade Program\n" << " -Main Menu-" << "\n\n";
+ cout << "1. Enter name\n";
+ cout << "2. Enter test scores\n";
+ cout << "3. Display test scores\n";
+ cout << "9. Exit\n\n";
+ cout << "Please enter your choice from the list above: ";
+
+ int user_input = 0;
+ cin >> user_input;
+
+ cout << "\n";
+
+ switch (user_input)
+ {
+ case 1:
+ cout << "This is where you would enter a name if this was more then a menu!\n";
+ break;
+ case 2:
+ cout << "This is where you would enter a test score if this was more then a menu!\n";
+ break;
+ case 3:
+ cout << "This is where you would see test scores if this was more then a menu!\n";
+ break;
+ case 9:
+ cout << "Goodbye\n";
+ break;
+ default:
+ cout << "Invalid input. Exiting\n";
+ return 1;
+ }
+
+ return 0;
+}
+*/
+
+//7.10 - Programing exercises #2
+
+//Pesudocode:
+/*
+DISPLAY promt for interest rate
+GET interest rate from user
+
+DISPLAY promt for loan amount
+GET loan amount from user
+
+IF interest rate is out of range
+DISPLAY error message
+
+IF loan amount is out of range
+DISPLAY error message
+
+IF loan amount is greater than the threshold
+MOVE high fee into varible charge
+OTHERWISE
+MOVE low fee into varible charge
+
+Calculate the interest of the loan amount and add it to varible charge
+
+DISPLAY charge
+*/
+
+/*
+int main()
+{
+ float interest_rate = -1.00F;
+ float principal = -1.00F;
+ float fee = 0.00F;
+ float payment = -1.00F;
+
+ cout << "Enter the interest rate (in percent) of the loan: ";
+ cin >> interest_rate;
+
+ cout << "\nEnter the principal (in USD) of the loan: ";
+ cin >> principal;
+ cout << endl;
+
+ if (interest_rate > 18)
+ {
+ cout << "Interest rate is too high\n";
+ return (1);
+ }
+ else if (interest_rate < 1)
+ {
+ cout << "Interest rate is too low\n";
+ return (2);
+ }
+
+ if (principal > 1000.00F)
+ {
+ cout << "Principal is too large\n";
+ return (3);
+ }
+ else if (principal < 100.00F)
+ {
+ cout << "Principal is too small\n";
+ return (4);
+ }
+
+ if (principal > 500.00F)
+ fee = 25.00F;
+ else
+ fee = 20.00F;
+
+ payment = principal * (interest_rate / 100);
+ payment += fee;
+
+ cout << "\n\nThe payment due for this billing cycle is ";
+ cout.setf(ios::fixed);
+ cout.setf(ios::showpoint);
+ cout.precision(2);
+ cout << payment << " USD\n";
+
+ return (0);
+}
+*/
+
+//8.2 - Learn by doing exercises #1
+
+int main()
+{
+ int max_value = -1;
+
+ cout << "Enter an interger between 1 and 50: ";
+ cin >> max_value;
+
+ //Filter invalid input
+ if ((max_value < 1) || (max_value > 50))
+ {
+ cout << "\n Invalid input";
+ return (1);
+ }
+
+ cout << "The even numbers between " << max_value << " and 0 are: " << endl;
+
+ //Check if even, remove 1 if not
+ if ((max_value % 2) != 0)
+ {
+ max_value--;
+ }
+
+ while (max_value >= 0)
+ {
+ cout << max_value << endl;
+ max_value -= 2;
+ }
+
+ return (0);
+}
+
+//8.4 - Learn by doing exercises #1
+
+//Pseudocode:
+/*
+* DISPLAY loop-length prompt
+* GET num_asign
+*
+* FOR num_asign:
+* DISPLAY score prompt
+* GET num_asign, ADD to scores
+*
+* DIVIDE scores by num_asign
+* DISPLAY scores
+*/
+
+/*
+int main()
+{
+ unsigned int num_asign = 0;
+ float score = 0.0F, temp_score = 0.0F;
+
+ cout << "Enter the number of asignments: ";
+ cin >> num_asign;
+ cout << "\nEnter each score as a percent.\n\n";
+
+ for (int idx = 0; idx < num_asign; idx++)
+ {
+ cout << "Enter score " << idx + 1 << " : ";
+ cin >> temp_score;
+ score += temp_score;
+ cout << endl;
+ }
+
+ score = score / num_asign;
+
+ cout << "The average score is: " << score << endl;
+
+ return (0);
+}
+*/
+
+//8.4 - Learn by doing exercises #2 (NOT IN PROBLEM SET)
+
+/*
+int main()
+{
+ int tri_height = 0;
+ cout << "Enter size of triangle: ";
+ cin >> tri_height;
+ cout << endl;
+
+ if (tri_height > 0)
+ {
+ tri_height--;
+ }
+ else
+ {
+ cout << "Invalid size";
+ return (1);
+ }
+
+ for (tri_height; tri_height >= 0; tri_height--)
+ {
+ for (int tri_width = tri_height; tri_width >= 0; tri_width--)
+ cout << "* ";
+ cout << endl;
+ }
+ return (0);
+}
+*/
+
+//8.10 - Programing exercises #3
+
+//Pseudocode:
+/*
+* DISPLAY user prompt for maximum sequence value
+* GET max_value
+*
+* IF max_value < 1, end
+* ELSE IF max_value = 1, DISPLAY 1, 1
+* ELSE:
+*
+* DISPLAY 1, 1, 2
+* working_v1 = 1
+* working_v2 = 2
+* working_v3 = 2
+*
+* WHILE working_v3 < max_value:
+*
+* working_v3 = working_v1 + working_v2
+* working_v1 = working_v2
+* working_v2 = working_v3
+*
+* DISPLAY working_v3
+*/
+
+/*
+int main()
+{
+ unsigned long long max_val = 0, working_v1 = 1, working_v2 = 1, working_v3 = 2;
+
+ cout << "Enter maximum positive integer for the Fibonacci sequence: ";
+ cin >> max_val;
+ cout << endl;
+
+ if (max_val == 0)
+ cout << "Not in sequence" << endl;
+ else
+ {
+ cout << "1\n1" << endl;
+ while (working_v3 < max_val)
+ {
+ cout << working_v3 << endl;
+ working_v3 = working_v1 + working_v2;
+ working_v1 = working_v2;
+ working_v2 = working_v3;
+ }
+ cout << endl;
+ }
+
+ return (0);
+}
+*/
+