summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorHannah Wu <[email protected]>2022-10-26 00:59:41 -0700
committerHannah Wu <[email protected]>2022-10-26 00:59:41 -0700
commitf99f0e45e58579dbb2ba1d19e7adaaee054a4083 (patch)
tree7cfd987328bb116df2bab1f1766419503f1967ad /BlankConsoleLab
parentadded calculation of aspect ratio and warning (diff)
downloadcst116-lab1-wu-f99f0e45e58579dbb2ba1d19e7adaaee054a4083.tar.xz
cst116-lab1-wu-f99f0e45e58579dbb2ba1d19e7adaaee054a4083.zip
edited loop. updated if else statements. added weight calculation and printout.
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index aee8676..e35bb49 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -12,17 +12,30 @@ using std::endl;
int main()
{
+ int i = 0;
float width, length;
- cout << "Enter the width of the kite in meters." << endl;
- cin >> width;
+ while (i == 0)
- cout << "Enter the length of the kite in meters." << endl;
- cin >> length;
-
- cout << "You have entered " << width << " for width." << endl;
- cout << "You have entered " << length << " for length." << endl;
+ {
+ cout << "Enter the width of the kite in meters. Please enter a value between 1 and 400." << endl;
+ cin >> width;
+
+ cout << "Enter the length of the kite in meters. Please enter a value between 1 and 400." << endl;
+ cin >> length;
+
+ if ((1 <= width && width <= 400) && (1 <= length && length <= 400))
+ {
+ cout << "You have entered " << width << " meters for width." << endl;
+ cout << "You have entered " << length << " meters for length." << endl;
+ i = 1;
+ }
+ else
+ {
+ cout << "Please only enter values between 1 and 400." << endl;
+ }
+ }
float ratio = (width / length);
@@ -34,7 +47,11 @@ int main()
float areacm = (width * length/2);
float areamt = (areacm / 10000);
- cout << "The area of the kite in square meters is " << areamt << endl;
+ cout << "Area of kite is " << areamt <<" square meters" << endl;
+
+ float mass = (areamt*135/1000);
+
+ cout << "Weight of kite is " << mass << "kg" << endl;