aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLTB-Pravda <[email protected]>2021-11-02 14:21:22 -0700
committerLTB-Pravda <[email protected]>2021-11-02 14:21:22 -0700
commit143414cf6102bb42ec50194eb7a5d0489a99e0fe (patch)
tree6963a17a7c3316d52dc85c4d9d3f788dd2afc2a6
parentAdd online IDE url (diff)
downloadcst116-lab3-ltb-pravda-master.tar.xz
cst116-lab3-ltb-pravda-master.zip
Updating GitHub Lab 3HEADmaster
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.cpp257
1 files changed, 241 insertions, 16 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp
index 41af613..e4e1919 100644
--- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp
+++ b/CST116F2021-Lab3/CST116F2021-Lab3.cpp
@@ -1,20 +1,245 @@
-// CST116F2021-Lab3.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
#include <iostream>
+using namespace std;
int main()
{
- std::cout << "Hello World!\n";
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
-
-// Tips for Getting Started:
-// 1. Use the Solution Explorer window to add/manage files
-// 2. Use the Team Explorer window to connect to source control
-// 3. Use the Output window to see build output and other messages
-// 4. Use the Error List window to view errors
-// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
+ /*
+ int sel;
+
+ cout << "\t Student Grade Program\n"
+ << "\t\t - Main Menu -\n\n";
+
+ cout << "\t1. Enter name\n"
+ << "\t2. Enter test scores\n"
+ << "\t3. Display test scores\n"
+ << "\t9. Exit\n\n";
+
+ cout << "Please enter your choice from the list above : ";
+
+ cin >> sel;
+
+ switch (sel)
+ {
+ case 1:
+ cout << "\nSelected to enter name.\n";
+ break;
+ case 2:
+ cout << "\nSelected to enter test scores.\n";
+ break;
+ case 3:
+ cout << "\nSelected to display test scores.\n";
+ break;
+ default:
+ cout << "\nExiting Program.\n";
+ }
+
+ cout << "\nRedirecting. . .\n";
+ */
+ //Set Variables
+ /*float rate;
+ float amount;
+ float interest;
+ int fee;
+ float total;
+
+ //Get Variables
+ cout << "Enter loan amount: ";
+ cin >> amount;
+
+ cout << "Enter interest rate: ";
+ cin >> rate;
+
+ //Validate
+ if (rate <= 0 || rate > 18)
+ {
+ cout << "Not a valid interest rate.\n";
+ return -1;
+ }
+ if (amount < 100 || amount > 1000)
+ {
+ cout << "Not a valid loan amount.\n";
+ return -2;
+ }
+
+ //Calc
+ if (amount <= 500 && amount > 100)
+ fee = 20;
+ else if (amount > 500 && amount <= 1000)
+ fee = 25;
+ else
+ {
+ cout << "Error calculating fee.\n";
+ return -3;
+ }
+
+ interest = amount * (rate / 100);
+ total = interest + fee;
+
+ //print
+ cout << "The loan has an amount of: " << amount << " and an interest rate of " << rate << endl
+ << "The total payment of interest and fees is: " << total << endl;*/
+
+ // 7.2 #1
+ /*
+ // Account Varibles
+ float money;
+ int accounts;
+ // Switch Operator
+ int sel;
+ // Set Varibles
+ cout << "Number of accounts: ";
+ cin >> accounts;
+
+ cout << "Total money: ";
+ cin >> money;
+ // Calc
+ if (money >= 25000)
+ sel = 1;
+ if (money < 25000 && accounts > 1)
+ sel = 2;
+ if (money < 25000 && accounts == 1)
+ sel = 3;
+ if (money <= 10000)
+ sel = 4;
+ if (money <= 0 || accounts <= 0)
+ sel = 0;
+
+ cout <<"\n\n";
+ // Output
+ switch (sel)
+ {
+ case 1:
+ cout << "The membership level is Platinum with $" << money << " dollars and " << accounts;
+ if (accounts = 1)
+ cout << " account\n\n";
+ else
+ cout << " accounts\n\n";
+ break;
+ case 2:
+ cout << "The membership level is Gold with $" << money << " dollars and " << accounts;
+ if (accounts = 1)
+ cout << " account\n\n";
+ else
+ cout << " accounts\n\n";
+ break;
+ case 3:
+ cout << "The membership level is Silver with $" << money << " dollars and " << accounts;
+ if (accounts = 1)
+ cout << " account\n\n";
+ else
+ cout << " accounts\n\n";
+ break;
+ case 4:
+ cout << "The membership level is Copper with $" << money;
+ if (money > 1)
+ cout << " dollars and " << accounts;
+ else if (money < 1)
+ cout << " cents and " << accounts;
+ else
+ cout << " dollar and " << accounts;
+
+ if (accounts = 1)
+ cout << " account\n\n";
+ else
+ cout << " accounts\n\n";
+ break;
+ default:
+ cout << "Something went wrong. Neither the number of accounts or amount of money can be 0 or negative.\n\n";
+ }
+ */
+ // 8.2
+ /*
+ int in;
+
+ cout << "Enter a number 1-50: ";
+ cin >> in;
+
+ if (in < 1)
+ {
+ cout << "Number cannot be 0 or negative";
+ return -1;
+ }
+ if (in > 50)
+ {
+ cout << "Number cannot be greater than 50";
+ return -2;
+ }
+
+ for (int c = in; c > 0; c--)
+ {
+ cout << c << ' ';
+ if (c % 10 == 1)
+ cout << endl;
+ }*/
+ // 8.3
+ /*
+ int in;
+
+ cout << "Enter a number 1-50: ";
+ cin >> in;
+
+ if (in < 1)
+ {
+ cout << "Number cannot be 0 or negative";
+ return -1;
+ }
+ if (in > 50)
+ {
+ cout << "Number cannot be greater than 50";
+ return -2;
+ }
+
+ do
+ {
+ cout << in << ' ';
+ if (in % 10 == 1)
+ cout << endl;
+ in--;
+ } while (in > 0);
+ */
+
+ /*
+ int in;
+
+ cout << "Enter a number size for the right triangle: ";
+ cin >> in;
+
+ if (in < 1)
+ {
+ cout << "Number cannot be 0 or negative";
+ return -1;
+ }
+
+ for (int h = in; h > 0; h--)
+ {
+ for (int w = h; w > 0; w--)
+ cout << "\* ";
+ cout << endl;
+ }
+ */
+ // 8.10
+ int num1 = 0,
+ num2 = 1,
+ num3;
+
+ int max;
+
+ cout << "What max number of the Fibonacci sequence would you like to display? ";
+ cin >> max;
+
+ cout << num1;
+
+ while (num2 < max)
+ {
+ cout << ", " << num2;
+ //Do the calc and shift the numbers over so calc can be done again.
+ num3 = num1 + num2;
+ num1 = num2;
+ num2 = num3;
+
+ }
+
+
+ return 0;
+
+} \ No newline at end of file