{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Exam 2 Sample Question Answers - 1 Sample Exam 2 Questions...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Sample Exam 2 Questions Problem #1 Based on the current balance in a money market account at a local Lafayette bank, two different bonus levels are applied to a base interest rate. The following MATLAB code applies after the variable current_balance has been assigned a value: i_rate = 0.7 if (current_balance >= 7500) & (current_balance < 25000) i_rate = i_rate + 0.65 elseif current_balance >= 25000 i_rate = i_rate + 1.3 end fprintf( ' Interest rate = %3.2f percent \n ' ,i_rate) a) Determine exactly what will be printed to the MATLAB command window for current_balance values of: i) 3,000 Interest rate = 0.70 percent ii) 40,000 Interest rate = 2.00 percent iii) 20,000 Interest rate = 1.35 percent b) Construct a flowchart from which the above MATLAB code could have been developed. Remember that no MATLAB code should appear in the flowchart. Assign interest rate Is balance between 7500 (included) and 25000? Is balance greater than or equal to 25000? Add 0.65 to interest rate Add 1.3 to interest rate Print interest rate F T T F Paths join (+1) 2 Problem #2 The following MATLAB code was written in a script file: clear all n=8; if n>=10 disp('Range 3') elseif n>=5 disp('Range 2') elseif n>=0 disp('Range 1') end a . (4 points) When the MATLAB script is executed, Range 2 is displayed. Why doesn’t Range 1 also display? The first true statement in an if structure is executed and then execution continues after the end statement. b . (4 points) Since someone reading the program could find it confusing that Range 1 does not display, how should the program be modified to avoid confusion? Each elseif could be a left and right bounded compound statement Problem #3 A phase diagram for Carbon and Platinum is shown below (Graphite is a particular phase of Carbon). After making a flowchart, a novice materials engineer knows enough to write the code below, but you need to finish it. All phase boundaries in the diagram are linear and the endpoints of the upper phase boundary line are shown. a. Line 1 defines the equation of the line for the boundary between the “L” and “L + Graphite” regions. Compute the slope and intercept for this line and write them on the answer sheet. b. Line 2 shows the condition to determine if the phase is “Pt + Graphite”. The engineer may have forgotten to include conditions in lines 4, 6 and 8. Assuming your equation in part “a” (above) is correct: L L + Graphite Pt + Graphite Eutectic line 3 • Determine if conditions are needed (check the appropriate box on the answer sheet). • If conditions are needed, write the correct condition on the answer sheet. 1. phase_line =____*massC + _____; % equation for phase boundary 2. if Temperature < 1700 % Solid mixture Phase 3. phase = 'Pt + Graphite'; 4. elseif ______________________ % Eutectic line 5. phase = 'Pt, Graphite, and Liquid'; 6. elseif ______________________ % Liquid Phase 7. phase = 'Liquid'; 8. else ______________________ % Liquid + graphite Phase 9. phase = 'Liquid + Graphite';...
View Full Document

{[ snackBarMessage ]}

### Page1 / 11

Exam 2 Sample Question Answers - 1 Sample Exam 2 Questions...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online