Question

The lab exercise this week (Week 03) was to write a program to compute the wing...

The lab exercise this week (Week 03) was to write a program to compute the wing loading value (WLV), defined as the weight of an airplane (in kg) divided by its wing area (in m^2). Airplanes with low wing loading values are easy to maneuver but uncomfortable. Airplanes with high wing loading values are more comfortable, but less maneuverable. In this exercise, an engineer is trying to design an aircraft with a WLV in the range 290.0 - 310.0, inclusive.

You're going to write a C++ program to help the engineer in their design work. The program will input two real numbers, the weight (in kg) followed by the wing area (in m^2), and then compute the WLV. If the WLV falls within the design range of 290.0 - 310.0, inclusive, the program outputs "design: good". However, if the WLV falls outside this range, the program outputs how the wing area should change to achieve a WLV of 300.0. Example: suppose the inputs are (denoting weight and wing area, respectively):

38000.0 124.5

In this case the WLV is 305.221, so the program outputs

WLV: 305.221
design: good

because the WLV falls with the design goal of 290.0 - 310.0, inclusive. Note there is one space following each ":", and each line should be followed by C++ endl. However, suppose the inputs are

32000.0
99.2

The WLV 322.581, which is too high --- and implies the wing is too small. So the program outputs

WLV: 322.581
design: increase wing area by 7.46667m^2

because the target wing area (TWA) for the given weight is 106.66667 (i.e. 32000.0/TWA = 300.0), and 106.66667 - 99.2 = 7.46667. Likewise, suppose the inputs are

28500.0
102.25

The WLV is 278.729, which is too low --- and implies the wing is too big. So the program outputs

WLV: 278.729
design: reduce wing area by -7.25m^2

because the target wing area (TWA) for the given weight is 95.0, and 95.0 - 102.25 = -7.25. Finally, if either of the inputs is negative, do not perform the computation and instead output 'invalid data!". This implies the program has exactly one output: either "invalid data!", or the wing loading value followed by design guidelines.

[ HINT: you have the equation for WLV. Compute the engineer’s target wing area based on the weight and desired WLV of 300.0. Then you’ll have what you need to compute the change in wing area. It's just one or two lines of C++ code to compute what you need. ]

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

Explanation::

  • Code in C++ is given below.
  • Please read all the comments for better understanding of the code.
  • Screenshots of the OUTPUT are provided at the end of the code.

Code in C++::

#include<iostream>
using namespace std;
int main(){
cout<<"________________________________"<<endl;
/**
* Two double variables named weight and wingArea are declared below.
* weight stores the weight of the airplane in kg
* wingArea stores the wing area in m^2
*/
double weight,wingArea;

/**
* Below we prompt user to enter the weight and wingArea
*/
cout<<"Enter Weight::";
cin>>weight;
cout<<"Enter Wing Area::";
cin>>wingArea;
if(weight<0 || wingArea<0){
/**
* If either of the input is negative then we print "invalid data!"
* and the program is over here
*/
cout<<"invalid data!"<<endl;
}else{
/**
* An double variable named WLV is declared and initialize using the formula.
*/
double WLV=weight/wingArea;

/**
* Below two double variables are declared named newWingArea and difference.
* newWingArea will store the value of division of weight/300
* difference will store the difference between new wing area and old wing area.
*/
double newWingArea,difference;

/**
* Below we just print the WLV value.
*/
cout<<"WLV: "<<WLV<<endl;

/**
* Now if the WLV is out of range 290.0 - 310.0 then we need to calculate
* newWingArea and difference as follows.
*/
if(WLV<290.0 || WLV>310.0){
newWingArea=weight/300.0;
difference=newWingArea-wingArea;
if(difference>=0){
cout<<"design: increase wing area by "<<difference<<"m^2"<<endl;
}else{
cout<<"design: reduce wing area by "<<difference<<"m^2"<<endl;
}
}else{
/**
* If WLV falls in range 290.0 to 310.0 then we print good design.
*/
cout<<"design: good"<<endl;
}
}
cout<<"________________________________"<<endl;
return 0;
}

OUTPUT::

Test Case 1::

Test Case 2::

Test Case 3::

Test Case 4::

Please provide feedback!!

Thank You!!

Add a comment
Know the answer?
Add Answer to:
The lab exercise this week (Week 03) was to write a program to compute the wing...
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
  • In this assignment you’re going to write a complete C program that opens a file “digits.txt”,...

    In this assignment you’re going to write a complete C program that opens a file “digits.txt”, inputs the values, and analyzes these values to see if they follow Benford’s law. In particular, your program analyzes the first digit of each input value, and outputs: 1. The total # of input values N 2. The counts for each digit: # of values that start with 1, # of values that start with 2, etc. 3. A histogram of the counts for...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

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