diff options
| author | Taylor Rogers <[email protected]> | 2022-10-17 20:22:37 -0700 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-10-17 20:22:37 -0700 |
| commit | 09f20f7f13ed59e2c177bdcc29c4286995ca2b82 (patch) | |
| tree | 0cfdcc55e61ad5fb8497c8e9edeb392a4e77a754 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | Added area variables (diff) | |
| download | cst116-lab1-taylorrog-09f20f7f13ed59e2c177bdcc29c4286995ca2b82.tar.xz cst116-lab1-taylorrog-09f20f7f13ed59e2c177bdcc29c4286995ca2b82.zip | |
Lots of changes
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 100 |
1 files changed, 94 insertions, 6 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; + + + } |