diff options
| author | alexandra-apetroaei <andra@MSI> | 2022-10-19 15:53:04 -0800 |
|---|---|---|
| committer | alexandra-apetroaei <andra@MSI> | 2022-10-19 15:53:04 -0800 |
| commit | b7b9f7239fc20a3043e5a640223a463b763b6d77 (patch) | |
| tree | 2bbb88a81c6c2070543e5c8e58373fee5a86c1e4 | |
| parent | added psuedocode (diff) | |
| download | cst116-lab1-alexandra-apetroaei-master.tar.xz cst116-lab1-alexandra-apetroaei-master.zip | |
| -rw-r--r-- | BlankConsoleLab/Lab1-Apetroaei.cpp | 68 | ||||
| -rw-r--r-- | psuedocode-Lab1.txt | 10 |
2 files changed, 58 insertions, 20 deletions
diff --git a/BlankConsoleLab/Lab1-Apetroaei.cpp b/BlankConsoleLab/Lab1-Apetroaei.cpp index c7dbbac..687ee4c 100644 --- a/BlankConsoleLab/Lab1-Apetroaei.cpp +++ b/BlankConsoleLab/Lab1-Apetroaei.cpp @@ -3,44 +3,68 @@ #include <iostream> -using namespace std; - using std::cout; using std::cin; using std::endl; -void keepKite(int width, int length) -{ - if (length < 1 && >400) - cout << "Enter new number!" << endl; -} + int main() { float width; float length; float area; - float number; + float mass; float aspect_ratio; - float isStable = false; + float grav_pull; + float isStable = true; + float range = false; - while (isStable == false) + + while (isStable == true) { - cout << "Insert width (in centimeters): " << endl; - cin >> width; + while (range == false) + { + cout << "Insert width (in centimeters): " << endl; + cin >> width; + + cout << "Insert length (in centimeters): " << endl; + cin >> length; - cout << "Insert length (in centimeters): " << endl; - cin >> length; - cout << "You entered: " << width << "cm for width, and " << length << "cm for length" << endl; + if (width < 1 && length < 1 && width > 400 && length > 400) + { + cout << "Keep range between 1-400." << endl; + } - - // Area formula - area = ((width * length) / 2) / 1000; - cout << "The area of the kite is: " << area << "in square meters" << endl; + else { + range = true; + break; + } + + } + + cout << "You entered:" << width << "cm for width and :" << length << "cm for length." << endl; + aspect_ratio = (width / length); + + //Compute total area + area = ((width * length) / 2) / 10000; + cout << "The area of the kite is: " << area << "in meters squared." << endl; + cin >> area; + + //Compute total mass + mass = (area * 135) / 10000; + cout << "The mass of your kite is: " << mass << " kilograms." << endl; + cin >> mass; + + //Compute gravitational pull + grav_pull = mass * 9.8; + cout << "The gravitional pull of your kite is: " << grav_pull << + "meters per second squared." << endl; + cin >> grav_pull; if (aspect_ratio >= 1) { @@ -51,12 +75,16 @@ int main() else { cout << "Aspect ratio:" << aspect_ratio << endl; + + break; } + + - return 0; } + } diff --git a/psuedocode-Lab1.txt b/psuedocode-Lab1.txt new file mode 100644 index 0000000..0f30ca7 --- /dev/null +++ b/psuedocode-Lab1.txt @@ -0,0 +1,10 @@ +Set variable width +Set variable length + +Aspect ratio = width * length + +Compute area of kite (width * length/2)/10000 +Compute mass of kite (area * 135)/10000 +Compute gravitational pull of kite (mass * 9.8) + +Read output
\ No newline at end of file |