summaryrefslogtreecommitdiff
path: root/CST116-Lab1-Bold.cpp
blob: 4b9c4ba4c136d1a91edba2a5b9da972988053ae1 (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
#include <iostream>

using namespace std;

using std::cout;
using std::cin;
using std::endl;

int main()
{
    float width = 0;
    float length = 0;
    float area = 0;
    float aspect_ratio = 0;
    const float fabric = 135;           // 135 gram per meter
    float grav = 0;                     // gravitation
    
    while (width < 1 || width > 400)        //I used while for the range of 1 to 400 
    {
        cout << "Enter the width in centimeters between 1 and 400 : ";
        cin >> width;
                       
    }

    while (length < 1 || length > 400)      //I used while for the length range as well. It will loop untill correct number entered.
    {
        cout << "Enter the length in centimeters between 1 and 400 : ";
        cin >> length;

    }
            
    cout << "\n\nYour width is " << width  << " and " << "length is " << length << " centimeters.\n\n";

    area = (((width * length) / 2) / 10000);        //Calculating total area here.
    grav = area * fabric;                           //Calculating gravitational pull.

    aspect_ratio = width / length;                  //Calcualting the aspect of ratio

    cout << "Total area:         " << area << " square meters." <<"\nGravitational pull: " << grav <<" gr.\n";
    cout << "The aspect ratio:   " << aspect_ratio;

    if (aspect_ratio >= 1)      // I used if statement 
        cout << "\nA lower aspect ratio provides more stability. \n\n";

    else cout << "\nThe aspect of ratio is good. \n\n";

    return 0;
}