blob: b008cd8ab0f39111fe61fc14abbc127079a1ff2b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Name: Logan Gillespie
// Class: CST 126
// Date: 3/31/24
// Assignment: Homework 1
#include <iostream>
using namespace std;
void moneyConverter();
void guessingGame();
void temperatureLog();
int main()
{
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() {
}
|