blob: 1322d6a760397575274c2da8e3a90dc05e3bd9a0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Andrei Florea - CST 116 - Lab 1 (Part 1 and Part 2) - Learning input, output, if statements, loops, simple
* calculations
*
* The purpose of this program is to take input regarding kite specifications and output
* if the kite is efficient at flying or if it is able to fly.
*
*/
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
int main()
{
float width = 0;
float length = 0;
float area, ratio;
double gravitational_pull;
// This will take in input for width and length in the range of 1, 400 inclusive. If it's outside the range,
// then the loop will repeat until given the correct values.
while(!(width <= 400 && width >= 1 && length <= 400 && length >= 1)) {
cout << "Please only enter WIDTH and LENGTH between 1 - 400" << endl;
cout << "Please enter the WIDTH of your kite in centimeters (decimals are OK): ";
cin >> width;
cout << "Please enter the LENGTH of your kite in centimeters (decimals are OK): ";
cin >> length;
}
cout << "Width: " << width << " CM" <<" | Length: " << length << " CM" << endl;
area = (width * length) / 2;
area /= 10000; // Converts the area from square centimeters to square meters
cout << "Area (in square meters): " << area << " M^2" << endl;
const float mass = (135 * area) / 1000; // Finds the total mass of the kite.
cout << "If your kite is using a medium weight fabric (135g/sq meter), "
"it is calculated to weigh: " << mass << " kg/meter^2"
<< endl;
gravitational_pull = mass * 9.8;
cout << "Gravitational pull on your kite is: " << gravitational_pull << " (mass * 9.8 N/kg)" << endl;
ratio = width / length; // Finds aspect ratio of kite
if(ratio >= 1){
cout << "Warning: a lower aspect ratio would provide more stability." << endl;
cout << "Current aspect ratio: " << ratio << " (width / length)"<< endl;
}
}
|