Week 2 Workshop

Week 2 Workshop - WS_ 1/26/11 Week 2 Workshop Ryan Curtis...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
WS_______ 1/26/11 Week 2 Workshop Ryan Curtis 1/ 10 Week 2 Workshop – Programming 2 Worksheet You’ll begin this workshop by pairing up with another student and sorting machine screws into containers. Your workshop leader has templates that you may use to identify different standard sizes of machine screws. You’ll then (individually) use this experience to create a flow chart and associated MATLAB code to record the sorting/counting. You should work though this worksheet during workshop today. You are expected to record the answer to each question posed. Be sure to save each of the programs created. 1. Decision Structures In preparation for workshop today you watched a presentation focused on decision structures. In this presentation you reviewed if-else-end structures, stacked-if structures, elseif structures, and nested-if structures. You also learned that the same algorithm can be programmed multiple ways, some of which are more efficient than others. Your programs should be efficient. 2. Sorting Think about the following situation. You are given a bag of machine screws and you wish to figure out how many of each size machine screws you have. Use the chart of machine screws provided (courtesy of and copyright by Bolt Depot Inc.), and use the screw number (4,6,8, 10 or 12) to identify the machine screw size. The #4 screw has a diameter of 0.112”, and succeeding numbers increase in diameter by 0.013”. Thus a #6 screw has (or should have) a shank (unthreaded portion) diameter of 0.138”. Machine screw numbers end at 12, larger machine screws are identified by their nominal shank diameter (e.g. ½ -20), followed by the number of threads per inch. For simplicity, we’ll avoid the larger and smaller sizes in this program and, initially, ignore the TPI (threads/inch) designation. Forget for a moment that you need to do this for many machine screws, and focus on an algorithm to identify which of several cups (one for each size) you should place a single machine screw in. Based on what you learned in the Programming 2 Presentation, which type of decision structure should you use? Nested-If On the next page, sketch the flowchart for an algorithm that will place a machine screw in the correct cup. The user will be asked to enter a value representing the size of the machine screw (sizes 6, 8, 10 or 12) the “action” to be done when the machine screw is placed in the cup should be an output statement announcing the size. Present your flowchart to the classmates around you and discuss with each other why you
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/02/2011 for the course ENGE 1114 taught by Professor Twknott during the Spring '06 term at Virginia Tech.

Page1 / 10

Week 2 Workshop - WS_ 1/26/11 Week 2 Workshop Ryan Curtis...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online