The input file tunnel.txt contains 17 wind-tunnel measurement pairs which consist of a flight-path angle (in degrees) and its corresponding coefficient of lift on each line in the file. The flight-path angles are sorted in ascending order. Write a program that reads the wind-tunnel data into an appropriate array(s), prints a message showing the range of angles that are covered in the data file, and then allows the user to enter a flight-path angle. If the angle is within the bounds of the data set, the program should then use linear interpolation to compute the corresponding coefficient of lift and display it on the screen. If the user’s input is outside the range, the program should print an error message indicating so. The program should keep asking the user to enter flight-path values as long as the user desires.
I have attached what I have so far. What I am having a problem figuring out is how i'm suppose to use the interpolation equation.
f(B ) = f(A) + [(B-A)/(C-A)] * [f( C)-f(A)]
I don't know how to get f(a) or f(c ). I attached my code and I really appreciate any help recieved because this one has me stumped. Thanks
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
double flight_path_angle[17], lift[17], f_a, fl_ang;
string filename;
ifstream tunnel;
cout << "Enter the name of the input file." << endl;
cin >> filename;
cout << endl;
tunnel.open(filename.c_str());
if( tunnel.fail())
{
cout << "File could not be opened.\n";
}
else
{
for (int k=0; k<=16; k++)
{
tunnel >> flight_path_angle[k] >> lift[k];
}
cout << "Range of flight-path angles: " << flight_path_angle[0] << " to " << flight_path_angle[16] << " degrees" << endl;
cout << "Please enter the flight-path angle in degrees: ";
cin >> fl_ang;
if (fl_ang < 21 || fl_ang > -4)
{
}
system("PAUSE");
return 0;
}
Attached File(s)
-
tunnel.txt (165bytes)
Number of downloads: 234
This post has been edited by jrc43: 29 March 2008 - 09:27 PM

New Topic/Question
Reply



MultiQuote



|