I'm trying to wirte a program that reads a from a input file. On one column of the input file is angle and the other is the coefficient. The program is supposed to let the user input an angle and look for the corresponding coefficient and use both to solve an equation. Also, the program should let the user know the angle range. This is my code so far but it is stating that anglemax, anglemin, coeffmax, ceffmin, "has no storage class or type specifier" when clearly I stated double for all four.
if(!tunnel.fail())
{
cout << "The file could not be found.";
exit(0);
}
else
{
double flightangle[20], coeff[20];
const int n=20;
while (!tunnel.eof())
{
for (int n =0; n<20; ++n) //initializing array
{
tunnel>>flightangle[n]>>coeff[n]; //setting the values to array
}
double anglemax, anglemin, coeffmax, coeffmin; //stating doubles for flight angle max min and coefficient max, min
anglemax = flightangle[n-1]; //max angle is in array n-1
anglemin = flightangle[n]; //min angle is set to 0
coeffmax = coeff[n-1];
coeffmin = coeff[n];
double input, output;
cout <<"Enter a angle from the range:"<< anglemax << "to:" << anglemin <<endl;
cout <<"Enter the angle: ";
cin >> input;
if(input<anglemax && input > anglemin)
{
output = [coeffmin + (input - anglemin) * (coeffmax -coeffmin)]/(anglemax - anglemin);
cout << "The coefficient of lift is: " << output << endl;
}
else
cout <<"Choose another angle, it is not within range." << endl;
return 0;
}
tunnel.close();
return 0;
}
}