blob: db75a9329f94f8dbdb9ae31e58ac4ee449fd3ea3 (
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
68
69
70
71
72
73
74
75
76
77
78
|
// 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;
using std::endl;
int main()
{
int width;
int length;
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 = (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 will provide more stability!\n" << endl;
}
else
cout << "Nice aspect ratio!" << 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;
}
|