Question

Flight-Path Angle (degrees) Coefficient of Lift -0182 0.056 0.097 0.238 0.421 0.479 0.654 0.792 0.924 1.035 1.076 1.103 1.120 1.121 1.121 1.099 1.059 0 10 12 14 15 16 17 18 19 20 21 Assume that we would like to use linear interpolation to determine the coefficient of lift for additional flight-path angles that are between -4 degrees and 21 degrees. Write a C 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following shows a sample program run using the input file tunnel.txt (user input in bold).

Range of flight-path angles: -4 to 21 degrees

Please enter a flight-path angle in degrees: -3
Lift coefficient for -3 degrees: -0.119

Would you like to enter another value (Y/N)? y
Please enter a flight-path angle in degrees: -5
****Sorry, -5 is not within data range****

Would you like to enter another value (Y/N)? Y
Please enter a flight-path angle in degrees: 5.5
Lift coefficient for 5.5 degrees: 0.59575

Would you like to enter another value (Y/N)? N


Here is the data file "tunnel.txt":

-4 -0.182
-2 -0.056
0 0.097
2 0.238
4 0.421
6 0.479
8 0.654
10 0.792
12 0.924
14 1.035
15 1.076
16 1.103
17 1.120
18 1.121
19 1.121
20 1.099
21 1.059


And here is my code:
Code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

//Define constants and declare function prototypes
const int T=100;
double maxval(const double x[], int n);
double minval(const double x[], int n);

int main()
{
// Declare objects
int tpts(0);
double y[T], flight_range, coef_lift;
string filename;
ifstream tunnel;

// Prompt user for file name and open date file.
cout << "Enter the name of the data file";
cin >> filename;
tunnel.open(filename.c_str());
if (tunnel.fail())
{
cout << "Error opeing input file\n";
}
else
{
// Read a data value from the file
tunnel >> flight_range >> coef_lift;

// While there is room in the array and
// end of file was not encountered,
// assign the value to the array and
// input the next value.
while (tpts <= T-1 && !tunnel.eof())
{
y[tpts] = flight_range;
tpts++;
tunnel >> flight_range;
}

// Find and print the maximum value
cout << "Range of flight-path angles: " << minval(y,tpts) << " to " << maxval(y,tpts) << " degrees"<< endl;



// Close file and exit program
tunnel.close();
}
return 0;
}

/* ------------------------------------------------------*/
/* This function returns the maximum */
/* value in the array x with n elements */

double maxval(const double x[], int n)
{
// Declare local objects
double max_x;

// Determine maximum value in the array
max_x = x[0];
for (int k=1; k<=n-1; k++)
{
if (x[k] > max_x)
max_x = x[k];
}

// Return maximum value
return max_x;
}

/* ------------------------------------------------------*/
/* This function returns the minimum */
/* value in an array x with n elements */

double minval(const double x[], int n)
{
// Declare objects
double min_x;
// Determine minimum value in the array
min_x = x[0];
for (int k=1; k<=n-1; k++)
{
if (x[k] < min_x)
min_x = x[k];
}

// Return minimum value
return min_x;

Add a comment
Know the answer?
Add Answer to:
Flight-Path Angle (degrees) Coefficient of Lift -0182 0.056 0.097 0.238 0.421 0.479 0.654 0.792 0.924 1.035...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT