Calculate wind chill

I am new to this and have no experience, so any help would appreciated. Here is my problem:
Wind Chill = 35.74 + 0.6215T – 35.75(V^0.16) + 0.4275T(V^0.16)
Note: Windchill Temperature is only defined for temperatures at or below 50 degrees F and wind speeds above 3 mph. Bright sunshine may increase the wind chill temperature by 10 to 18 degrees F.



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
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
     
using namespace std;
     
double windChillFactor (const double &v, const double &t)
{
     double w = 0.0;
     
     w = 35.74 + (0.6215*t) - 35.75 * pow(v,0.16) + (0.4257*t) * pow(v,0.16);
     
     return w;
}
     
int main()
{
     bool canRun = true;
            int input;
            double v = 0.0;
            double t = 0.0;
            double w = 0.0;
     

do
{
       cout << "Please enter the wind speed in miles per hour (v): ";
       cin >> v;
       
if (v <= 3)
{
       cout << "Wind speed is to slow, try again ";
       
}       
else if (input <= 3)
   canRun = false;
}

     
     
     
   cout << "Please enter the temperature in degrees Farenheit (t): ";
   cin >> t;
   
if (t <= 50)
{
       cout << "The tempature is to high, try again ";
       
}   
}
     
while(v > 3 && t >= 50);
     
   w = windChillFactor(v,t);
    
   cout << "Wind Chill is: " << w << endl;
}
     
return 0;



Last edited on
Did you check the errors shown by the compiler first. Most of your mistakes will be cleared if you do that.

You need to learn some basic things like :
1)Declaring a variable first and then initializing it.

2)Body of a function should be declared within brace brackets

3)Function Prototype should include the return type of the function

Then you could try splitting your expression in parts because it is complicated to solve it in one go. It is not a good idea to use system(pause)
I added my variables and now get an error at:
cout << "Please enter the temperature in degrees Farenheit (t): ";
says(expected unqualified-id below "while.
I have tried to understand the do while command but I am unsure.
I am trying to get it to reset if the 3 and below and the 50 and below are not met. I thought I had to use the else if command but unsure what I am doing.
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

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

double windChillFactor (const double &v, const double &t)
{
     double w = 0.0;

     w = 35.74 + (0.6215*t) - 35.75 * pow(v,0.16) + (0.4257*t) * pow(v,0.16);

     return w;
}

int main()
{
     bool canRun = true;
            int input;
            double v = 0.0;
            double t = 0.0;
            double w = 0.0;


do
{
    cout << "Please enter the wind speed in miles per hour (v): ";
    cin >> v;
    if (v <= 3)
    {
       cout << "Wind speed is to slow, try again ";
    }
    else if (input <= 3)
        canRun = false;


    cout << "Please enter the temperature in degrees Farenheit (t): ";
    cin >> t;

    if (t <= 50)
    {
       cout << "The tempature is to high, try again ";
    }
}

while(v > 3 && t >= 50);

   w = windChillFactor(v,t);

   cout << "Wind Chill is: " << w << endl;

system("pause");
return 0;
}



check this it works
Topic archived. No new replies allowed.