summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Rogers <[email protected]>2022-10-17 20:22:37 -0700
committerTaylor Rogers <[email protected]>2022-10-17 20:22:37 -0700
commit09f20f7f13ed59e2c177bdcc29c4286995ca2b82 (patch)
tree0cfdcc55e61ad5fb8497c8e9edeb392a4e77a754
parentAdded area variables (diff)
downloadcst116-lab1-taylorrog-09f20f7f13ed59e2c177bdcc29c4286995ca2b82.tar.xz
cst116-lab1-taylorrog-09f20f7f13ed59e2c177bdcc29c4286995ca2b82.zip
Lots of changes
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp100
-rw-r--r--CST116-Lab1-Pseudo-Code-Rogers.txt17
-rw-r--r--LabResults.txt24
3 files changed, 134 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index c6e35d5..0438244 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -1,34 +1,122 @@
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
+// Name: Taylor Rogers
+// CST116 Lab1
#include <iostream>
#include <iomanip>
-using namespace std;
-
using std::cout;
using std::cin;
using std::endl;
+using std::fixed;
+using std::showpoint;
+using std::setprecision;
+
int main()
{
int kwidth, klength;
- cout << "What is the width of the kite in centimeters?: ";
+ cout << fixed << showpoint << setprecision(2);
+
+ // Kite Parameters
+ cout << "What is the width of the kite in centimeters?: ";
cin >> kwidth;
+ while (kwidth < 1)
+ {
+ cout << "Please enter a width between 1 and 400 centimeters: ";
+ cin >> kwidth;
+
+ while (kwidth > 400)
+ {
+ cout << "Please enter a width between 1 and 400 centimeters: ";
+ cin >> kwidth;
+ }
+ }
+
+ while (kwidth > 400)
+ {
+ cout << "Please enter a width between 1 and 400 centimeters: ";
+ cin >> kwidth;
+
+ while (kwidth < 1)
+ {
+ cout << "Please enter a width between 1 and 400 centimeters: ";
+ cin >> kwidth;
+ }
+ }
+
cout << endl;
cout << "What is the length of the kite in centimeters? ";
cin >> klength;
- int karea = (kwidth * klength) / 2;
- int ksqm = karea / 10000;
+ while (klength < 1)
+ {
+ cout << "Please enter a length between 1 and 400 centimeters: ";
+ cin >> klength;
+
+ while (klength > 400)
+ {
+ cout << "Please enter a length between 1 and 400 centimeters: ";
+ cin >> klength;
+ }
+ }
+
+ while (klength > 400)
+ {
+ cout << "Please enter a length between 1 and 400 centimeters: ";
+ cin >> klength;
+
+ while (klength < 1)
+ {
+ cout << "Please enter a length between 1 and 400 centimeters: ";
+ cin >> klength;
+ }
+ }
+
+
+ // Math
+ float karea = ( ((float)kwidth) * klength ) / 2;
+ float ksqm = karea / 10000;
+ float kasp = ((float)kwidth) / klength;
+ float kmass = ksqm * 0.135;
+ float kgrav = kmass * 9.8;
+
+
+ cout << endl;
+ // Kite Parameter Output
cout << "The kite is " << kwidth << " centimeters wide and " << klength << " centimeters long." << endl;
cout << endl;
- cout << "The kite has an area of " << ksqm << " square meters." << endl;
+ cout << "The kite has an area of " << ksqm << " square meters." << endl;
+
+ cout << endl;
+
+ // Kite Aspect Ratio
+ if (kasp >= 1)
+ cout << "An aspect ratio of <1 will provide more stability. The current aspect ratio is " << kasp << "." << endl;
+
+ else
+ cout << "Your aspect ratio is " << kasp << "." << endl;
+
+ cout << endl;
+
+ // Kite Mass
+ cout << "Assuming a canvas weight of 135g per square meter, the mass of your kite is ";
+ cout << kmass << "kg." << endl;
+
+ cout << endl;
+
+ // Kite Gravitational Pull
+ cout << "The gravitational pull on your kite is ";
+ cout << kgrav << "N." << endl;
+
+
+
}
diff --git a/CST116-Lab1-Pseudo-Code-Rogers.txt b/CST116-Lab1-Pseudo-Code-Rogers.txt
new file mode 100644
index 0000000..4a88571
--- /dev/null
+++ b/CST116-Lab1-Pseudo-Code-Rogers.txt
@@ -0,0 +1,17 @@
+Lab 1 Pseudo Code
+1. Print "What is the width of the kite in centimeters?:"
+2. Input [kwidth]
+ a. Width input must be 1 < [kwidth] < 400
+3. Print "What is the length of the kite in centimeters?"
+4. Input [klength]
+ a. Length input must be 1 < [klength] < 400
+5. Determine kite area using [karea] = ( [kwidth] * [klength] ) / 2
+6. Convert to meters squared using [ksqm] = [karea] / 10000
+7. Calculate aspect ratio using [kasp] = [kwidth] / [klength]
+8. Calculate mass using [kmass] = [ksqm] * 0.135
+9. Calculate gravitational pull using [kgrav] = [kmass] * 9.8
+10. Print "The kite is [kwidth] centimeters wide and [klength] centimeters long"
+11. If [kasp] is equal to or greater than 1, print "An aspect ratio of <1 will provide more stability. The current aspect ratio is [kasp]"
+ a. Else print "Your aspect ratio is [kasp]"
+12. Print "Assuming a canvas weight of 135g per square meter, the mass of your kite is [kmass]kg."
+13. Print "The gravitational pull on your kite is [kgrav]N"
diff --git a/LabResults.txt b/LabResults.txt
index bfe34d2..95d6869 100644
--- a/LabResults.txt
+++ b/LabResults.txt
@@ -1 +1,23 @@
-RunResults \ No newline at end of file
+RunResults:
+
+What is the width of the kite in centimeters?: 0
+Please enter a width between 1 and 400 centimeters: 500
+Please enter a width between 1 and 400 centimeters: 320
+
+What is the length of the kite in centimeters? 500
+Please enter a length between 1 and 400 centimeters: 0
+Please enter a length between 1 and 400 centimeters: 246
+
+The kite is 320 centimeters wide and 246 centimeters long.
+
+The kite has an area of 3.94 square meters.
+
+An aspect ratio of <1 will provide more stability. The current aspect ratio is 1.30.
+
+Assuming a canvas weight of 135g per square meter, the mass of your kite is 0.53kg.
+
+The gravitational pull on your kite is 5.21N.
+
+C:\Users\taylo\Source\Repos\CST116\cst116-lab1-Taylorrog\Debug\BlankConsoleLab.exe (process 23576) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . . \ No newline at end of file