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

D Che m 1800 w v Labs-Engine DMicrosoftW o × Dhttps://uoitble \"Content-Intr x D

ID: 3676028 • Letter: D

Question

D Che m 1800 w v Labs-Engine DMicrosoftW o × Dhttps://uoitble "Content-Intr x DRyerson Polyt Assignment-3 DElectricChage×VGAn electron t x G Physics Archiv nacebook https://uoit.blackboard.com/bbcswebdav/pid-752630-dt-content-rid-41 36137-1/courses/20160170610.201 601/Assignment-3-ENGR-1200U-W2016-R2.pdf Apps Bookmarks UOIT M UOIT.netBlackboardMyCampus Library ITSC Bibliography - Cite LON-CAPA Mastery.... physics reviewl W physics review2 physics view3Buy best selling ani... Enginee × ontent - Intrc X xeLON-CAPA MaxG Mechanical En × muataz must. nm.l+ University of Ontari.. 3. Linear Interpolation. The following problem refer to the wind-tunnel test data stored in the file tunnel.dat (contents are below). The file contains the set of data which consists of a flight-path angle (in degrees) and its corresponding coefficient of lift on each line in the file. The flight-path angles will be in ascending order Write a program that reads the wind-tunnel test data and then allows the user to enter a flight-path angle. If the angle is within the bounds of the data set, the pro- gram should then use linear interpolation to compute the corresponding coefficient of lift. o Lift-Coefficient 0.182 -0.056 0.097 0.238 0.421 0.479 0.654 0.792 0.924 1.035 1076 1.103 1.120 1.121 1.121 1.099 1.059 4 10 12 14 15 16 18 19 20 21 Utilize functions and arrays in your answer Assignment 3 Introduction to Programming ENGR 1200U Winter 2016 STS Major Essay Gu docx STS Major Essay Gu docx STS Journal Inform....docx STS Journal Inform....docx Show all downloa 6:34 PM "rt: .111 lls, 3/7/2016 0

Explanation / Answer

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

double coeffiecient(double a, double b, double c, double f_a, double f_c)
{
double f_b = f_a ;
f_b = f_b + (((b - a) / (c - a)) * (f_c - f_a)); // Computer lift coef with use of linear interpolation

return f_b;
}


int main()
{
// Declare variables
double range[17], a=0, b=0, c=0;
double coef[17], f_a=0, f_b=0, f_c=0;
char repeat, N, n;
int j;
double ra,co;
int i=0;

// open data file "tunnel.dat"
ifstream file_("tunnel.dat");
if (file_.fail()) // Check to see if file opened
{
cout << "Error opening data file 'tunnel.dat'" << endl;
}
else // If opened successfully, continue with code
{
while(file_ >> ra >> co )
{
range[i] = ra;
coef[i] = co;
i++;
}

file_.close(); // Closes "tunnel.dat"
cout << "Range of flight-path angles:" << range[0] << " to " << range[16] << " degrees" << endl;
cout << endl;
do
{
cout << "Please enter a flight-path angle in degrees: ";
cin >> b; // Get flight path angle from user

if (b < range[0] || b > range[16]) // Test to see if angle is outside flight-range
{
cout << "**** Sorry, " << b << " is not within data range ****" << endl;
cout << endl;
cout << "Would you like to enter another value (Y/N)?";
cin >> repeat;
cout << endl;
} // If angle is inside flight-range
else
{
for (j = 0; j <= 16 ; j++) // Find values of a and f_a
{
if(range[j] >= b)
{
a = range[j];
f_a = coef[j];

c = range[j-1];
f_c = coef[j-1];

break;

}

}

f_b = coeffiecient(a,b,c,f_a,f_c);

cout << endl;
cout << "Lift coeffiecient for " << b << " degrees: " << f_b << endl;
cout << "Would you like to enter another value (Y/N)?";
cin >> repeat;
cout << endl;
}
}
while (!(repeat == 'N' || repeat == 'n')); // Conditon for do loop
}

return 0; // Program ended successfully
}