SAN JOS STATE UNIVERSITY Department of Mechanical and Aerospace Engineering ME 30 Computer Applications Week 3 Lab Project Decision Structures Introduction In this lab you will learn about controlling the execution of a program using decision structures Objectives Following completion of today s lab you should be able to Explain what a decision structure does in structured programming List and describe the three kinds of decision structures Write C programs using decision structures Procedure If there are not enough computers to work at individually then find a partner to work with If you do work with a partner make sure that you take turns at the keyboard during the lab session Download a copy of the Lab Report Template lab rpt tpt doc from Desire2learn or the ME 30 website Use the template to record your answers to the lab exercises Make sure that you fill out the cover page completely before turning in your report Points will be deducted if the cover sheet is not completely filled out Enter your last name first initial and project number in the labeled boxes in the header by double clicking on it Under the section of the cover sheet labeled Summary summarize the problem s you solved You must also include a summary of the strategy you used as well as the methods you employed and any observations or conclusions about what you learned from the laboratory This is perhaps the most important part of the lab so do a good job on it Note that you are not limited to fitting the summary on the cover sheet You can expand the summary to another sheet if needed Save your work on your own USB storage device or email a softcopy to yourself before you leave the lab The hard drives on the computers in the lab are frequently refreshed so do not rely on them for saving your work from session to session Instructions for turning in your Lab Project report Save your report using the following naming convention all lower case lastname firstinitial sec n lab3 report doc where n is your lab section number Tues 2 Wed 3 Thurs 4 so if your name is John Smith and you are in section 3 you must name your file smith j sec 3 lab3 report doc Upload your report and any related files to Desire2Learn under the Week 3 Lab Project Dropbox before the deadline Turn in a hard copy of your report at the beginning of next week s lab session BJ Furman ME 30 Computer Applications Week3LabProject doc 08FEB2010 Page 1 of 2 SAN JOS STATE UNIVERSITY Department of Mechanical and Aerospace Engineering ME 30 Computer Applications Laboratory Exercises Follow the instructions below and enter your work in the Lab Report Template You may want to refer to your textbook to help you do the exercises Read the Notes below each table before you start on the exercises listed in that table 1 Write a program in C that will get a temperature from the user and its unit either Fahrenheit or Celsius Depending on which unit is entered the program converts and prints the temperature in the other unit Your program should request that the user enter the temperature as floating point type a Include both pseudocode and a flowchart to the logic of your program b Verify that your program works properly 2 Write a program in C that simulates reading a temperature sensor and taking an action based on the temperature value Simulate the reading by prompting a user for a temperature value in degrees C Test to see that the value is within the range of 0 to 100 C If the temperature reading is over 100 C print a message like Too hot If the temperature reading is less than 0 C print a message like Too cold If the temperature is in range and is greater than 40 C print a message like Turning on fan else if less than 20 C then print a message like Turning on heater or else print a message like No action taken a Include both pseudocode and a flowchart to the logic of your program b Verify that your program works properly 3 Write a program in C that ask the user to choose his or her favorite ice cream flavor from a list of choices which includes chocolate vanilla and strawberry Requirements 1 If some choice other than what your list shows is entered your program should display Sorry we don t carry that flavor Hint what decision structure is good for multiple choices 2 If chocolate is chosen then your program should determine which type Double Dark or Chocolate Fudge 3 After the selection is made the program prints out the name of the flavor chosen and a message name of flavor chosen Good choice a Develop the logic of your program in either pseudocode or a flowchart b Verify that your program works properly BJ Furman ME 30 Computer Applications Week3LabProject doc 08FEB2010 Page 2 of 2
View Full Document