blob: b37bc8127e07b8ab85be305d7de9234c93b7cf42 (
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
|
// 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;
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 in square meters is: " << area << 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;
}
mass = mass_per * area;
cout << "The total mass of your kite is: " << mass << " kg." << endl << endl;
return 0;
}
|