summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Williams <[email protected]>2022-10-13 16:46:57 -0700
committerJoseph Williams <[email protected]>2022-10-13 16:46:57 -0700
commit0416025a68e6126cc9e045d27c397cb1599d6005 (patch)
treeea25b045f2acd8a17ac0f172c0039572910cde6d
parentCompleted step 2 (Print what the user entered for width and height). Continue... (diff)
downloadcst116-lab1-allthenamesaretaken3141-0416025a68e6126cc9e045d27c397cb1599d6005.tar.xz
cst116-lab1-allthenamesaretaken3141-0416025a68e6126cc9e045d27c397cb1599d6005.zip
Completed steps 3-5 (compute area, convert to square meters, print to user). Recalibrated emotional simulations for increased sarcasm.
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ff2bf87..2390a6e 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -36,9 +36,9 @@ void multiColorPrint(vector<tuple<string, int, bool> > text, HANDLE console = hC
}
//Super messy and really just here because if you're reusing more than one line, you're doing something wrong.
-int getWidthOrHeight(string d)
+float getWidthOrHeight(string d)
{
- int input;
+ float input;
vector<tuple< string, int, bool> > text;
text.push_back(make_tuple("Please enter the ", 15, false));
text.push_back(make_tuple(d, 13, false));
@@ -59,18 +59,32 @@ int getWidthOrHeight(string d)
return input;
}
+//Return the kite's area in square meters.
+float calulateKiteArea(float width, float height)
+{
+ return ((width * height) / 2) / 10000;
+}
+
int main()
{
- int width, height;
+ float width, height;
colorPrint("Welcome to Kite Calculator!\n", 11);
- colorPrint("Let's start with getting the dimensions of your kite!", 9);
+ colorPrint("Let's start with getting the dimensions of your kite. Or not, I wouldn't mind a break.", 9);
width = getWidthOrHeight("width");
height = getWidthOrHeight("height");
cout << endl;
+
//Tell the user what they just entered, because...reasons.
- colorPrint("Great job!", 10);
- multiColorPrint(vector<tuple< string, int, bool> > {make_tuple("Your kite is ", 15, false), make_tuple(to_string(width) + "cm", 13, false), make_tuple(" wide and ", 15, false), make_tuple(to_string(height) + "cm", 13, false), make_tuple(" high.", 15, true), });
- colorPrint("I'm sure it's beautiful!", 11);
+ colorPrint("Great job. You can type numbers on a keyboard. I'm soooo proud of you.", 10);
+ multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite is ", 15, false), make_tuple(to_string(width) + "cm", 13, false), make_tuple(" wide and ", 15, false), make_tuple(to_string(height) + "cm", 13, false), make_tuple(" high.", 15, true), }); //I hate this but its still better than stacking like 20 couts.
+ colorPrint("I'm sure it's beautiful. Or maybe not. I don't know you.\n", 9);
+
+ //Calculate the kite's area and tell it to the user.
+ float area = calulateKiteArea(width, height);
+ multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite has an area of ", 15, false), make_tuple(to_string(area) + " square meters", 11, false), make_tuple(". ", 15, false), make_tuple("Remind me why I agreed to do this, again?", 9, true)});
+ cout << endl;
+
+ return 0;
} \ No newline at end of file