summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
blob: 734c153a00b8c77d04cd43f8629da00c33e6f6c6 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
// 
// Name: Taylor Rogers
// Assignment: Lab 2
// 
// Pseudo Code:
// 1. Print "Please enter F for Fahrenheit, or C for Celsius"
//      1. Declare constant [Fmax] = 121
//      2. Declare constant [Fmin] = -80
//      3. Declare constant [Cmax] = 49.5
//      4. Declare constant [Cmin] = -62
// 2. Input [Tunit]
// 3. If [Tunit] = F is selected:
//      1. Print "Enter temperature value between -80 and 121 degrees Fahreneit"
//      2. Input [TvalF]
// 4. If [Tunit] =  C is selected:
//      1. Print "Enter temperature value between -52 and 49.5 degrees Celsius"
//      2. Input [TvalC]
// 6. Print "Enter a wind speed, in miles per hour, between 0 and 231"
//      1. Declare constant [Wmax] = 231
//      2. Declare constant [Wmin] = 0
//      3. Input [Wspeed]
// 7. F input function:
//      1. Declare [FtoCval] = ( [TvalF] - 32 ) * ( 5 / 9 )
//      2. [TvalC] = [FtoCval]
// 8. C input function:
//      1. Declare [CtoFval] = (9 / 5 ) * [TvalC] + 32
//      2. [TvalF] = [CtoFval]
// 9. Windchill function:
//      1. [Wchill] = 35.74 + .6215 * [TvalF] - 35.75 * ( [Wspeed] ^ 0.16 ) + 0.4275 * [TvalF] * ( [Wspeed] ^ 0.16 )
// 10. Print headers "Temperature in F" , "Temperature in C", "Windpseed", "Windchill"
// 11. Print [TvalF] , [TvalC] , [Wspeed] , [Wchill]
// 


#include <iostream>
#include <math.h>
#include <iomanip>


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


const int Fmax = 121;
signed const int Fmin = -80;
const int Cmax = 49.5;
signed const int Cmin = -62;
const int Wmax = 231;
const int Wmin = 0;

char Tunit{};
float TvalF{};
float TvalC{};
int Wspeed{};
float Wchill{};

// Converts Fahrenheit to Celsius
float FtoCfunc(float FtoCval)
{
    FtoCval = 0;
    FtoCval = (TvalF - 32) * (5 / 9);
    return FtoCval;
}

int main()
{

    // Temp unit selection
    cout << "Please enter F for Fahrenheit or C for Celsius: ";
    cin >> Tunit;
    cout << endl;

    cout << "Please enter temperature: ";

    // Temp input in F
    if (Tunit == 70)
    {
        cin >> TvalF;

        while (TvalF < Fmin)
        {
            cout << "Please enter a value greater than " << Fmin << ": ";
            cin >> TvalF;

            while (TvalF > Fmax)
            {
                cout << "Please enter a value less than " << Fmax << ": ";
                cin >> TvalF;
            }
        }

        while (TvalF > Fmax)
        {
            cout << "Please enter a value less than " << Fmax << ": ";
            cin >> TvalF;

            while (TvalF > Fmin)
            {
                cout << "Please enter a value greater than " << Fmin << ": ";
                cin >> TvalF;
            }
        }
    }

    // Temp input in C
    else if (Tunit == 67)
    {
        cin >> TvalC;

        while (TvalC < Cmin)
        {
            cout << "Please enter a value greater than " << Cmin << ": ";
            cin >> TvalC;

            while (TvalC > Cmax)
            {
                cout << "Please enter a value less than " << Cmax << ": ";
                cin >> TvalC;
            }
        }

        while (TvalC > Cmax)
        {
            cout << "Please enter a value less than " << Cmax << ": ";
            cin >> TvalC;

            while (TvalC > Cmin)
            {
                cout << "Please enter a value greater than " << Cmin << ": ";
                cin >> TvalC;
            }
        }
    }

    else
        cout << "Invalid unit" << endl;


    //Windspeed
    cout << "Please enter the windpeed in Miles Per Hour: ";
    cin >> Wspeed;

    while (Wspeed < Wmin)
    {
        cout << "Please enter a value greater than " << Wmin << ": ";
        cin >> Wspeed;

        while (Wspeed > Wmax)
        {
            cout << "Please enter a value less than " << Wmax << ": ";
            cin >> Wspeed;
        }
    }

    while (Wspeed > Wmax)
    {
        cout << "Please enter a value less than " << Wmax << ": ";
        cin >> Wspeed;

        while (Wspeed > Wmin)
        {
            cout << "Please enter a value greater than " << Wmin << ": ";
            cin >> Wspeed;
        }
    }

    cout << endl;

    cout << setw(20) << "Temp in C" << setw(20) << "Temp in F" << setw(20) << "Wind Speed" << setw(20) << "Wind Chill" << endl;

    cout << setw(20) << TvalC << setw(20) << TvalF << setw(20) << Wspeed << setw(20) << Wchill << endl;

    cout << FtoCfunc;

    cout << endl;

}







// Converts Celsius to Fahrenheit
void CtoFfunc(float CtoFval)
{
    CtoFval = (9 / 5) * TvalC + 32;
    //TvalF = CtoFval;
    //cout << TvalF;
}

// Converts Windspeed and Temp to Winchill
void Wchfunc(float Wchill)
{
    Wchill = 35.74 + .6215 * TvalF - 35.75 * (pow(Wspeed, 0.16)) + 0.4275 * TvalF * (pow(Wspeed, 0.16));
    //cout << Wchill;
}