sentinel controlled loop

I have all my code and it works perfect but one of my requirements is that the program should allow the user to perform several wind chill factor calculations in a single run but I just can't seem to get it right. I am trying to use a char with a continue question because of the validation requirements I can not use wind speed or temperature as the variable. Can someone help me on this?
Here is my code:
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
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;



//Function prototypes

void    userInput(int& temp, int& windSpeed);
double  compute_windChill (int temp, int windSpeed);
void    output (int temp, int windSpeed, double result);


//--------------------------------------------------------------

int main()
{

    //Declare variables

    int temp, windSpeed;
    double   windChill;
	
    

    //Call functions

    userInput(temp, windSpeed);
    windChill = compute_windChill(temp, windSpeed);
    output(temp, windSpeed, windChill);

    return 0;

}

//--------------------------------------------------------------

void userInput (int& temp, int& windSpeed)
{

    cout << "Please enter the temperature: " << endl;
    cin     >> temp;
    cout << "Please enter the wind speed: " << endl;
    cin  >> windSpeed;

    while ((temp < -45 || temp > 45) || (windSpeed < 3 || windSpeed >60))

    {

        cout << "Data is out of range!:" << endl;
        cout << "Temperature must be from -45 to 45 degrees" <<endl;
		cout <<	"and the wind speed must be from 3 - 60 mph" << endl;
        cout << "Please enter the temperature: " << endl;
        cin     >> temp;
        cout << "Please enter the wind speed: " << endl;
        cin  >> windSpeed;
    }

}

//--------------------------------------------------------------

double compute_windChill(int temp, int windSpeed)

{
    double windChill;
    windChill = 35.74 + (0.6215 * temp) - (35.75 * pow(windSpeed,.16)) + (.4275 * temp) * pow(windSpeed,.16);
    return windChill;
}


//--------------------------------------------------------------

void output (int temp, int windSpeed, double windChill)

{
    cout << "The temperature is: " << temp            << endl;
    cout << "The wind speed is: "  << windSpeed        << endl;
    cout << fixed <<showpoint << setprecision(1) << "The wind chill is: "  << windChill << endl;
}

something like this?

1
2
3
4
5
6
while(input == 'y')
{
    cout << "do you want to continue?" << endl;
    cout << "y/n" << endl;
    cin >> input;
}
Here is a better way to quit from a loop:

http://www.cplusplus.com/forum/beginner/84889/#msg455481


Hope all goes well.
Topic archived. No new replies allowed.