blob: efce74fa006bb274e6570b90b2c49000060d3e97 (
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
59
60
61
62
63
64
65
66
67
|
// CST116-Lab1-Smith.cpp : This file contains the 'main' function. Program execution begins and ends there.
/*Benjamin Smith
* CST116
* Lab 1
* Input and Output and If statements
* Loops and Simple Calculations
*/
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
//Initializing Variables
float w, l, area, aspect_ratio, mass, grav_pull;
const float mass_per = .135;
int main()
{
//Collecting the length and width of the kite in centimeters
cout << "Please input the width of the kite in centimeters." << endl;
cin >> w;
while (w < 1 || w > 400) {
cout << "That number is invalid. Please try again with a number between 1 and 400." << endl;
cin >> w;
}
cout << "Now please input the length of the kite in centimeters." << endl;
cin >> l;
while (l < 1 || l > 400) {
cout << "That number is invalid. Please try again with a number between 1 and 400." << endl;
cin >> l;
}
//Doing the math to convert the centimeter inputs to square meter outputs
area = (w * l) / 2;
area /= 10000;
//Displaying the area in square meters
cout << "The area of the kite will be: " << area << " m^2." << endl << endl;
//Setting the aspect ratio of width to length
aspect_ratio = w / l;
//Determining if the aspect ratio is too high
if (aspect_ratio >= 1) {
cout << "Your aspect ratio of width to length is: " << aspect_ratio << ", which is quite high." << endl << "It is recommended to use a smaller aspect ratio to maintain stability." << endl << endl;
}
//Calculate then output the mass of the kite
mass = mass_per * area;
cout << "The total mass of your kite will be: " << mass << " kg." << endl << endl;
//Calculate then output the gravitational pull of the kite
grav_pull = mass * 9.8;
cout << "The gravitational pull on your kite will be: " << grav_pull << " N/kg." << endl;
return 0;
}
|