-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloworld.cpp
More file actions
205 lines (169 loc) · 5.31 KB
/
helloworld.cpp
File metadata and controls
205 lines (169 loc) · 5.31 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include <iostream>
#include <string>
using namespace std;
//Compiler version g++ 6.3.0
// I am just adding to comment to do a push for my today's commit. nothing else
int main()
{
// Declare some nice variables
string message = "",
tempType = "°F",
goToCollegeText = "temp",
gpaLetterText = "temp";
int favNum, age, fage, fNum, sNum;
double idealTemp;
bool goToCollege;
char gpaLetter; // only fill if you select true to goToCollege
// set up constants
const float PI = 3.1415926535897932384626433832795028841971;
const int cNum = 25,
minsPerHour = 60,
secsPerMin = 60,
hoursPerDay = 24,
minsPerDay = hoursPerDay * 60,
secsPerDay = minsPerDay * 60;
// UPDATE: Version 2.0.0 - ask user for input
// set up message
//message = "Hello world\n"; //manual
cout << "Welcome to HelloWorld! This is an app that is basic in it's self.\n";
cout << "It can do alot of things. But first, tell me what you want me to remember: ";
// NOTE: This will not work properly
//cin >> message;
// as it won't be able to take whitespace.
// You must use something like this:
getline(cin, message);
// and it will work nicely
cout << "\nGreat! Now I will ask you some questions." << endl;
// set up ideal temp
//idealTemp = 75.6; //manual
cout << "What temperature (in " << tempType << ") outside do you like? ";
cin >> idealTemp;
// set up favNum
//favNum = 420; // manual input
cout << "What is your favorite number? ";
cin >> favNum;
// set up age
//age = 29; //manual
cout << "How old are you? ";
cin >> age;
// set up fage (fake age)
//fage = 907; //manual
cout << "Really, how old are you? ";
cin >> fage;
// set up goToCollege
//goToCollege = true;
do
{
string s = goToCollegeText;
cout << "\nDid you go to college? ";
getline(cin, s);
if (s == "temp")
{
// no input yet
s = "1";
}
else
{
if (s == "yes" || s == "Yes" || s == "YES")
{
goToCollege = true;
break;
}
else if (s == "no" || s == "No" || s == "NO")
{
goToCollege = false;
break;
}
else
{
//return 0;
cout << "\nERROR: You must reply 'yes' or 'no'!\n";
}
}
} while (true);
// set up gpaLetter
//gpaLetter = 'B'; // manual
if (goToCollege)
{
do
{
string s = gpaLetterText;
cout << "\nWhat was your GPA (in letter form) ";
getline(cin, s);
if (s == "temp")
{
// no input yet
s = "1";
}
else
{
if (s == "A" || s == "a")
{
gpaLetter = 'A';
break;
}
else if (s == "B" || s == "b")
{
gpaLetter = 'B';
break;
}
else if (s == "C" || s == "c")
{
gpaLetter = 'C';
break;
}
else if (s == "D" || s == "d")
{
gpaLetter = 'D';
break;
}
else if (s == "F" || s == "f")
{
gpaLetter = 'F';
break;
}
else
{
//return 0;
cout << "\nERROR: That is not a valid entry.\n";
}
}
} while (true);
}
// set up some numbers for later
fNum = 69;
sNum = 420;
cout << "\n=== Results ===========================\n\n";
// Add to message with some stuff
message += "\n\n";
message += "I am learning to code C++ (again)!\n";
message += "I am using a tiny keyboard writing\n";
message += "this code on my Android Note 9 Phone.\n";
// Display the result
cout << message << endl;
// Display another sentence
cout << "This sentence ends with endl" << endl << endl;
cout << "There are " << secsPerDay << " seconds in a day.\n";
cout << "============== About Me ===============\n\n";
cout << "I am " << age << " years old but really\n";
cout << "I am " << fage << " years old; shh...\n";
cout << "I like it when it is " << idealTemp << tempType << " degrees outside.\n";
// do a conditional check for college
if (goToCollege)
cout << "In college, my GPA was a solid: " << gpaLetter << "\n";
cout << "\nI can do some math:\n";
cout << fNum << " + " << sNum << " = " << fNum+sNum << endl;
cout << "-- This is how many digits of PI I know --\n";
// BUG: This doesn't display the long list and only displays the
// first 6 digits
cout << PI << endl;
cout << "------------------------------------------\n";
cout << "\n=======================================";
// Let's see if we can change cNum
// If you uncomment the line below, it will
// throw an error.
//cNum += 25;
//cout << "The constant number: " << cNum << endl;
system("pause");
return 0;
}