Can someone please help? My assignment is to display a chart using loops, not allowed to hard code any numeric values below the headings. The user is given three options if someone could help me get started with the first chart, I can get the rest. I have included my code for what I have written so far. I tried starting the loop but I don't think that its correct.

Assignment - A user is to enter a temperature validated at 50 or below, the temp is to decrease by 5 until 5 rows have been displayed. Calculate the wind chill temp values for each temp using wind speeds of 10, 20, and 30

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

double WindChill(double AirT, double WS)
{
	double WindChill;
	WindChill = 35.74 + .6215*(AirT) - 35.75*pow(WS,.16) + .4275*(AirT)*pow(WS,.16);
	return WindChill;
}

double HeatIndex(double DryT, double RHumidity)
{
	double HeatIndex;
	HeatIndex = -42.379 + 2.04901523*(DryT) + 10.14333127*(RHumidity) - 0.22475541*(DryT)*(RHumidity) -
		6.83783*pow(10,-3)*pow(DryT,2) - 5.481717*pow(10,-2)*pow(RHumidity,2) + 1.22874*pow(10,-3)*pow(DryT,2)*RHumidity
		+ 8.5282*pow(10,-4)*DryT*pow(RHumidity,2) - 1.99*pow(10,-6)*pow(DryT,2)*pow(RHumidity,2);
	return HeatIndex;

}
int main()
{

	double AirT;
	double WS;
	double DryT;
	double RHumidity;
	double response;

	cout << "Please Make a Selection from the Following Menu:\n";
	cout << "\n";
	cout << "1) Display Wind Chill Chart\n";
             cout << "2) Display Heat Index Chart\n";
	cout << "3) Quit\n";
		cin >> response;


	if (response == 1) //&& AirT < 50)
	{	
		if (AirT > 50)
		{
			cout << "Temperature is not valid, please enter another temperature\n";
		}
		
	cout << "Enter the Air Temperature:\n";
		cin >> AirT;

		cout << "\t \t \t \t \t \t Chipola Weather Service" << endl;
		cout << "\t \t \t \t \t \t \t Wind Chill Chart" << endl;
		cout << endl;
		cout << endl;
		cout << "Temp in \t \t \t \t \t WindSpeed in mph" << endl;
		cout << "Degrees F \t \t 10 \t \t \t 20 \t \t \t 30" << endl;
		const int Width = 10;
		const int Max_Wind = 30;
		const int Min_Wind = 10;
		int WS;
		int temp; //= AirT;

		for (WS = Min_Wind; WS >=Max_Wind; WS += 10)
		{
			cout << setw(Width) << WS;
		}
cout << endl << endl;

		for (temp = AirT; AirT < 50; temp -= 5)
		{
		
			cout << setw(Width) << int (WindChill(AirT,WS));
		}
	}


	
		return 0;

}

<< moderator edit: added [code][/code] tags >>

hey
wat exactly is your trouble
u ve got all ur formulas rite i suppose then where is the difficulty

I found a few things you might want to look at:

for (WS = Min_Wind; WS >=Max_Wind; WS += 10)

you want to do this while WS is lager than Max_Wind? think that WS <= Max_Wind is better.

for (temp = AirT; AirT < 50; temp -= 5)

you are testing the AirT (AirT < 50;) you probarly want to check temp(temp < 50;)instead, since that is the variable you are changing

if (AirT > 50)
{
cout << "Temperature is not valid, please enter another temperature\n";
}

cout << "Enter the Air Temperature:\n";
cin >> AirT;

Might want to move the if to afer you have asked for AirT

If you want WS to change in the last for loop you need to do somthing like this:

for (int WS = Min_Wind; WS < Max_Wind; WS +=10)
{
    for (temp = AirT; temp < 50; temp -= 5)
    {
        cout << WindChill(temp,WS);
    }
}

your last loop had a little error:

for (temp = AirT; AirT < 50; temp -= 5)
{

cout << setw(Width) << int (WindChill(AirT,WS));
}

you use the function WindChild with AirT instead of temp.

This article has been dead for over six months. Start a new discussion instead.