diff options
| author | prestonderek <[email protected]> | 2022-10-19 20:39:27 -0700 |
|---|---|---|
| committer | prestonderek <[email protected]> | 2022-10-19 20:39:27 -0700 |
| commit | 491a296dca6d75c7c4bfdd4df666292c2ef80095 (patch) | |
| tree | f477e61a14f34763303b7326fa9e59f475e9d8cb /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | Commit for part 1 complete (diff) | |
| download | cst116-lab1-prestonderek-491a296dca6d75c7c4bfdd4df666292c2ef80095.tar.xz cst116-lab1-prestonderek-491a296dca6d75c7c4bfdd4df666292c2ef80095.zip | |
Commit for Part 2 complete
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index e80106c..db75a93 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -1,7 +1,8 @@ // BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. -// +//Changes are being made 10/19 for PART 2 #include <iostream> +#include <iomanip> using std::cout; using std::cin; @@ -14,24 +15,64 @@ int main() float areaCM; float areaM; float ratio; + float totalMass; + float kiteGravPull; + //for the input while loops + const int botnum = 1; + const int topnum = 400; + + const int FabricWeight = 135; + const float pull = 9.8; + cout << "Please enter the length of your kite." << endl; cin >> length; + //while length is out of bounds + while (length < botnum || length > topnum) + { + cout << "Please enter a value for length between 1 and 400." << endl; + cin >> length; + } + cout << "\nPlease enter the width of your kite." << endl; cin >> width; + + //while width is out of bounds + while (width < botnum || width > topnum) + { + cout << "Please enter a value for length between 1 and 400." << endl; + cin >> width; + } + cout << "Your kite has a length of: " << length << "cm, and a width of: " << width << "cm." << endl; cout << "\n"; + //Mathmatics areaCM = (width * length) / 2; areaM = areaCM / 10000; - ratio = width / length; + ratio = (float)width / (float)length; + totalMass = (areaM * FabricWeight) / 1000; + kiteGravPull = totalMass * pull; + //makes sure the floats are printed with 5 decimals + cout << std::setprecision(5); + cout << std::fixed; + + cout << "Your kite has an aspect ratio of: " << ratio << endl; + cout << "\n"; + + //Aspect Ratio if statement if (ratio >= 1) { - cout << "WARNING: A lower aspect ratio \nwill provide more stability!\n" << endl; + cout << "WARNING: A lower aspect ratio will provide more stability!\n" << endl; } + else + cout << "Nice aspect ratio!" << endl; - cout << "Your kite has an area of: " << areaM << " square meters" << endl; + //Output + cout << "\nYour kite has an area of: " << areaM << " square meters" << endl; cout << "Your kite has an area of: " << areaCM << " square centimeters" << endl; + cout << "Your kite is " << totalMass << " grams." << endl; + cout << "Your kite has a gravitational pull of: " << kiteGravPull << endl; } |