engr 141 sample exam one

6
ENGR 141 – Sample Exam One Handout: Fall 2011 DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not necessarily reflect ALL the material or question formats that will appear on the exam. Sample Exam Q1. Sketch a complete flowchart that represents the following written algorithm. Input the height of person 1 [in units of feet] as P1 Input the height of person 2 [in units of feet] as P2 If P1 > P2 Display “Person 2 is shorter” Otherwise, if P2 > P1 Display “Person 1 is shorter” Otherwise, display “They are the same height” Answer the following questions in the space provided. If any of the calculations are not possible, write "Not Possible" in the space. Do not leave the space blank! [ ] [ ] [ ] [ ] [ ] [ ] Sample Exam Q2. What are the dimensions of C? Sample Exam Q3. What are the dimensions of L 2 ? Sample Exam Q4. What is the index of the number 15 in matrix C? Sample Exam Q5. What is the index of the number 12 in matrix E? Sample Exam Q6. What is the result of E + M? Sample Exam Q7. What is the result of N – S? Sample Exam Q8. What is the result of E * L? Sample Exam Q9. What is the result of 2 * M? Sample Exam Q10. What is the result of S + 3? Sample Exam Q11. What is the result of N T ? Sample Exam Q12. What is the result of E 2 ?

Upload: tyler-harvey

Post on 12-Oct-2014

111 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

Sample Exam Q1. Sketch a complete flowchart that represents the following written algorithm.

Input the height of person 1 [in units of feet] as P1

Input the height of person 2 [in units of feet] as P2

If P1 > P2

Display “Person 2 is shorter”

Otherwise, if P2 > P1

Display “Person 1 is shorter”

Otherwise, display “They are the same height”

Answer the following questions in the space provided. If any of the calculations are not possible,

write "Not Possible" in the space. Do not leave the space blank!

[

] [

] [

]

[

] [

] [

]

Sample Exam Q2. What are the dimensions of C?

Sample Exam Q3. What are the dimensions of L2?

Sample Exam Q4. What is the index of the number 15 in matrix C?

Sample Exam Q5. What is the index of the number 12 in matrix E?

Sample Exam Q6. What is the result of E + M?

Sample Exam Q7. What is the result of N – S?

Sample Exam Q8. What is the result of E * L?

Sample Exam Q9. What is the result of 2 * M?

Sample Exam Q10. What is the result of S + 3?

Sample Exam Q11. What is the result of NT?

Sample Exam Q12. What is the result of E2?

Page 2: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

Sample Exam Q13. What one line MATLAB command would you type in the command window to

define the following as the variable G:

[

]

Sample Exam Q14. What one line MATLAB command will store the text “Curious George’s Book” in

the variable YellowHat?

Sample Exam Q15. Write an input statement to ask the user to enter their shoe size as a number and

put the response in the variable SizeOfShoe. (e.g. they can enter 7, 6.5, etc.)

Sample Exam Q16. Write an input statement to ask the user to “Enter your mother’s maiden name:”

and put the response in the variable MaidenNameMother.

Sample Exam Q17. We want to restrict the week day a user can select. Only weekdays (M – F)

should and be selected. Write the MATLAB code necessary to allow a user to pick a weekday to

schedule an appointment. Save the user’s response in the variable DayOfAppt.

Sample Exam Q18. What is displayed by the following command? If nothing, leave the line on the

answer page blank.

num = 22/7;

fprintf('Value 1: %4.3f \nValue 2: %.2f\n ',num,pi*10);

Sample Exam Q19. What is displayed by the following command? If nothing, leave the line on the

answer page blank. Draw an arrow (-->) to indicate where any tabs occur in the output.

A = [1 2; 3 4];

fprintf('\t%.2f\n\t\t%.0f\n ',A(1,1),A(2,1))

Page 3: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

Sample Exam Q20. Write the MATLAB code to display the value in the variable Rate inside the

sentence shown below where you see the blank (___) space. You may assume that the variable

Rate will contain a single number and should be displayed to one decimal place.

The bank's interest rate is ____%.

For example, if the value in Rate is 7.4, the output statement would generate:

The bank's interest rate is 7.4%.

Sample Exam Q21. For what integer values of x will the following statements display x as output?

if (x >= 2) && (x < 6)

fprintf(x)

end

Sample Exam Q22. For what integer values of x will the following statements display x as output?

if (x > 0) && (x ~= 3) && (x <= 5)

fprintf(x)

end

Sample Exam Q23. We have the menu shown below in a MATLAB program. Write a program to

generate this menu and display the choice of the user in a sentence like: “You bought a Coke.”

Assume the result of clicking an option in the menu is saved in a variable called soda in the

workspace.

Page 4: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

A phase diagram for Cobalt and Nickel is shown below. If it is assumed the lines shown are linear, the

mixture has the following characteristics:

o Above 1500 °C, it is a liquid (L).

o Below 1500 °C, there are two possible phases: face-centered cubic (FCC) phase and

hexagonal close packed (HCP) phase.

Sample Exam Q24. Ask the user to input the weight percent nickel in a variable w and the

temperature [°C] in a variable T.

Sample Exam Q25. Write the polyfit code to determine the equation of the line dividing the HCP

and FCC phases.

Sample Exam Q26. Write a conditional statement to determine the phase. Call the phases "HCP",

"FCC", "L", "FCC+L" (on the line), and "HCP+FCC" (on the line) for simplicity. Store the phase as text

in a variable called Phase.

Page 5: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

Sample Exam Q27. Write a MATLAB program to create a proper plot of the following set of data

collected during the charging of a capacitor. In this plot, time should be on the abscissa. Be sure

to use the correct graph type (theoretical or experimental) to represent this problem. Based on

the graph type chosen, you may use any valid symbol or line type to represent this data in your

plot. For this problem, you do NOT need to include the proper header information—just the code.

Time (t) [s] 0 0.2 0.4 0.6 0.8 1.0

Voltage (V) [V] 0 75.9 103.8 114.0 117.8 119.2

Sample Exam Q28. Write the MATLAB code necessary to create a proper plot using the plot

function of the theoretical voltage decay of a resistor-capacitor circuit:

( )

You may assume that you have a capacitance (C) of 500 microfarads [µF], a resistance (R) of 0.5

ohms [Ω], and an initial voltage (V_0) of 10 volts [V]. The plot should start at time 0 seconds and

increase by intervals of 1 second to 600 seconds.

Sample Exam Q29. If an object is heated, the temperature of the body will increase. The energy (Q)

associated with a change in temperature (ΔT) is a function of the mass of the object (m) and the

specific heat (Cp), which is the rate at which the object will lose or gain energy. In an experiment,

heat is applied to the end of an object, and the temperature change at the other end of the

object is recorded. This leads to the theoretical relationship shown below. An unknown material is

tested in the lab with a mass of 5 kilograms, yielding the following results. Use the polyfit

function to determine the specific heat of this material and store the final result in the variable

C_p. Note that no values should be hard coded EXCEPT for the variables you create to store the

experimental data.

T

m Cp

Heat Energy Applied (Q) [J] 17 40 58

Temperature hange (ΔT) [K] 2.00 5.00 7.00

Page 6: ENGR 141 Sample Exam One

ENGR 141 – Sample Exam One

Handout: Fall 2011

DISCLAIMER: These questions are meant to provide an EXAMPLE of a 141 exam. They do not

necessarily reflect ALL the material or question formats that will appear on the exam.

Sample Exam Q30. Write only the function header for a function, named myDistFn, which takes in

two X, Y coordinates stored in the variables point1 and point2, and returns the distance

between the points stored in the variable dist.

Sample Exam Q31. A member of your team gives you the following MATLAB program.

Your job is to create the functions used in the program. A = 10; % area [cm^2]

H = 30; % height [cm]

V = 50; % volume [cm^3]

% The following function calculates the radius [cm] of the circle with area of A [cm^2]

R1 = RadiusCircle(A);

% The following function calculates the radius [cm] of a cone with height H [cm] and

% volume V [cm^3]

R2 = RadiusCone(H,V);

Remember:

Area of a circle = π r2

Volume of a cone = 1

3𝜋𝑟2𝐻