aboutsummaryrefslogtreecommitdiff
path: root/CST 126/Homework 1/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST 126/Homework 1/main.cpp')
-rw-r--r--CST 126/Homework 1/main.cpp102
1 files changed, 100 insertions, 2 deletions
diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp
index 5d25e6d..b008cd8 100644
--- a/CST 126/Homework 1/main.cpp
+++ b/CST 126/Homework 1/main.cpp
@@ -1,12 +1,110 @@
// Name: Logan Gillespie
// Class: CST 126
// Date: 3/31/24
-// Assignment: Homework
+// Assignment: Homework 1
#include <iostream>
using namespace std;
+void moneyConverter();
+void guessingGame();
+void temperatureLog();
+
int main()
{
- cout << "Hello World" << endl;
+ int choice = 0;
+ do {
+ cout << "Welcome to our program! Here are your options:" << endl;
+ cout << "0. Quit" << endl;
+ cout << "1. Money Converter" << endl;
+ cout << "2. Guessing Game" << endl;
+ cout << "3. Temperature Log" << endl;
+ cin >> choice;
+ switch (choice) {
+ case 1:
+ moneyConverter();
+ break;
+ case 2:
+ guessingGame();
+ break;
+ case 3:
+ temperatureLog();
+ break;
+ }
+ } while (choice != 0);
+}
+
+void moneyConverter() {
+ float usd = 1.00;
+ float euro = 0.94;
+ float baht = 36.98;
+ float rupee = 298.73;
+ float pound = 0.80;
+ string from;
+ string to;
+ float amount = 0.00;
+ float interim = 0.00;
+ cout << "Options:\nUSD\nEuro\nBaht\nRupee\nPound\n";
+ cout << "Which curency to convert from?\n";
+ cin >> from;
+ cout << "Which curency to convert to?\n";
+ cin >> to;
+ cout << "How much of the starting curency?\n";
+ cin >> amount;
+ if (from == "Euro" || from == "euro") {
+ interim = amount / euro;
+ }
+ else if (from == "Baht" || from == "baht") {
+ interim = amount / baht;
+ }
+ else if (from == "Rupee" || from == "rupee") {
+ interim = amount / rupee;
+ }
+ else if (from == "Pound" || from == "pound") {
+ interim = amount / pound;
+ }
+ else if (from == "USD" || from == "usd") {
+ interim = amount;
+ }
+ if (to == "Euro" || to == "euro") {
+ interim = interim * euro;
+ }
+ else if (to == "Baht" || to == "baht") {
+ interim = interim * baht;
+ }
+ else if (to == "Rupee" || to == "rupee") {
+ interim = interim * rupee;
+ }
+ else if (to == "Pound" || to == "pound") {
+ interim = interim * pound;
+ }
+ cout << amount << " " << from << " converts to " << interim << " " << to << endl;
+}
+
+void guessingGame() {
+ srand(time(NULL));
+ int guess = 0;
+ int tries = 0;
+ int target = rand() % 10001;
+ while (guess != target && tries < 20) {
+ cout << "Enter your guess" << endl;
+ cin >> guess;
+ if (guess < target) {
+ cout << "The number is higher." << endl;
+ }
+ else if (guess > target) {
+ cout << "The number is lower." << endl;
+ }
+ tries = tries + 1;
+ }
+ if (tries < 20) {
+ cout << "Congrats! No one remembers the losers" << endl;
+ }
+ if (tries == 20) {
+ cout << "Too Bad! All your base are belong to us" << endl;
+ }
+}
+
+void temperatureLog() {
+
} \ No newline at end of file