Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

test chamber, and then measurements of the forces on the model can be made at ma

ID: 639895 • Letter: T

Question

test chamber, and then measurements of the forces on the model can be made at many different wind speed and angles. At the end of an extended wind tunnel test, many sets of data have been collected and can be used to determine the coefficients of lift, drag, and other aerodynamic performance characteristics of the new aircraft at its various operational speeds and positions. Data collected from a wind tunnel test are plotted in the following figure and are listed in a table in the text book. Assume that we would like to use linear interpolation to determine the coefficients of lift for additional flight-path angles that are between -4 degrees and 21 degrees. Write a program that allows the user to enter the data for two points and a flight-path angle between those points. The program should then compute the corresponding coefficient of lift.

Explanation / Answer

Complete Program:

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

const int SIZE = 17;
double getResult(const double x[], const double y[], double b);

int main()
{
double angles[SIZE];
double lifts[SIZE];
double n, degr, result;

ifstream fin("input.txt");

if(fin.fail())
{
  cerr << "Input file is not opened" << endl;
  system("pause");
  exit(1);
}

for(int i = 0; i < SIZE; i++)
{
  fin >> angles[i] >> lifts[i];
}

cout << "Please enter a flight-path angle in degrees: ";
cin >> degr;

if(degr < -4 || degr > 21)
  cout << "The flight-path angle is not in range." << endl;
else
{
  result = getResult(angles, lifts, degr);
  cout << "The lift coefficient for the given degrees: " << setprecision(5) << fixed << result << endl;
}

fin.close();

system("pause");
return 0;
}


double getResult(const double angles[], const double lifts[], double degr)
{
double result;

for(int i = 0; i < SIZE; i++)
{
  if(degr == angles[i])
   result = lifts[i];
  else
   result = lifts[i] + ((degr - angles[i]) / (angles[i] - angles[i + 1])) * (lifts[i] - lifts[i + 1]);
}

return result;
}