ENGR 132 Spring 2023 A07 ∙ IF Structures and WHILE Loops Introduction Assignment Goals This assignment focuses on two different types of non-sequential structures: selection (if) structures and indefinite (while) loops. For each topic, you will gain programming experience coding a structure and then you will apply those skills to an engineering context. You will also learn to differentiate structure types in flowcharts. Successful Completion This assignment has four (4) problems. Problems 1 and 3 go with Class A; Problems 2 and 4 go with Class B. Problems 3 and 4 have a team component. 1. Read Notes Before You Start, on Page 1. 2. Read each problem carefully. You are responsible for following all instructions within each problem. a. Problems 1 and 3 require selection structures. Problems 2 and 4 require indefinite loops. b. The deliverables list within each problem contains everything you are expected to submit. c. You will need the problem generator A07_skills.p for Problems 1-2. See this link to view instructions. 3. Complete the problems using the problem-specific m-file templates when a template is provided. For any file, replace template or login in the filename with your Purdue Career Account login. 4. Review your work using the learning objective evidences. 5. When your work is complete, confirm your deliverables are submitted to Gradescope. • • This homework has two Gradescope submission assignments for the individual submissions, plus a third assignment for the team planning component. A07 – Problems 1-2: Submit Problems 1 and 2 individually. Help link. o A07 – Problems 3-4: Submit individual work for Problems 3 and 4. Help link. o A07 – Team Planning: Submit team plans for Problems 3 and 4 as a group. Help link. You can submit to Gradescope as many times as you need. Only your final submission is graded. o 6. o You must submit all files for Problems 3 and 4 at the same time. Help link. • Do NOT upload any document not listed in the deliverables. Do not upload temporary versions of mfiles (*.m~ or *.asv) – these files will be ignored by Gradescope. • You must submit an m-file when one is requested; failing to do so will result in a 0 on the problem. Late submissions will be accepted up to 24 hours after the due date and will result in a 25% penalty. Learning Objectives & Grading This course uses learning objectives (LOs) to assess your work. You can find a full list of the course LOs here. Review the grading outline at the end of each problem in this assignment to see each problem’s LOs. Notes Before You Start Helpful MATLAB Commands Learn about the following built-in MATLAB commands, which might be useful in your solutions: if, elseif, else, end, input, while, disp, sqrt Page 1 of 13 ENGR 132 Spring 2023 Problem 1: MATLAB Skills – Selection Structures Introduction This problem allows you to practice writing a selection structure. You will submit your answers to an online assignment on Gradescope. Problem Generator Information Review this link that shows step-by-step instructions for the problem generator, if needed. File Name PUID Problem Number A07_skills Your 8-digit PUID 1 Submission Gradescope Assignment A07 – Problems 1-2 Assignment Type Deliverables Requested information and A07Prob1_selection_login.m Individual Problem Below is a flowchart that contains basic instructions in the shapes. To get the specific instructions for this flowchart, you will need to use the problem generator. The instruction text will provide you with the conditions and resulting commands. Match the text with the corresponding instructions in the flowchart. Instructions 1. Enter the problem generator function call into the MATLAB Command Window prompt. 2. Read the written instruction text that appears in the Command Window. Write a script to complete the task. • Use the included template to write the requested code. Page 2 of 13 ENGR 132 Spring 2023 • Maintain the order of the items in the flowchart. Even if there is a different approach you could take to the solve the problem, you must follow the exact order and instructions in the flowchart. • You can test your structure with any integer for A. Good testing will attempt every path in the structure. • Programming standards will not be assessed in this problem. Do not include comments in your solutions. Properly name the file. 3. Submit your instruction text with run receipt and m-file into Gradescope. 4. Save your answers in Gradescope. See this video for help (this is an untimed assignment). Grading LOs: PC05, MAT03, MAT07 Point value: 6 points. The partial credit may be more specific than what is in the course LOs and is based on evidence MAT03 (5) and MAT07. If you do not meet the PC05 expectations, you will lose additional credit. Evidence Penalty PC05 (1) PC05 (2) PC05 (3) PC05 (4) Lose full credit on problem Lose 25% of full credit on problem Lose 25% of full credit on problem Lose 15% of full credit on problem Page 3 of 13 ENGR 132 Spring 2023 Problem 2: MATLAB Skills – While Loop Introduction This problem allows you to practice writing an indefinite loop repetition structure. You will submit your answers to an online assignment on Gradescope. Problem Generator Information Review this link that shows step-by-step instructions for the problem generator, if needed. File Name PUID Problem Number A07_skills Your 8-digit PUID 2 Submission Gradescope Assignment A07 – Problems 1-2 Assignment Type Deliverables Requested information, solutions, and A07Prob2_while_login.m Individual Problem Below is a flowchart that contains basic instructions in the shapes. Use the problem generator to get specific instructions for the flowchart. The instruction text will provide you with the conditions and resulting commands. Match the text with the corresponding instructions in the flowchart. Instructions 1. Enter the problem generator function call into the MATLAB Command Window prompt. 2. Read the written instruction text that appears in the Command Window. Write a script to complete the task. • Use the included template to write the requested code. • Maintain the order of the items in the flowchart. Even if there is a different approach you could take to the solve the problem, you must follow the exact order and instructions in the flowchart. • Run your script to test your loop and generate the requested information. • Programming standards will not be assessed in this problem. Do not include comments in your solutions. Properly name the file. 3. Submit your instruction text with run receipt, solutions, and m-file into Gradescope. 4. Save your answers in Gradescope. See this video for help (this is an untimed assignment). Page 4 of 13 ENGR 132 Spring 2023 Grading LOs: PC05, MAT07 Point value: 6 points. The partial credit may be more specific than what is in the course LOs and is based on evidence in MAT07. If you do not meet the PC05 expectations, you will lose additional credit. Evidence Penalty PC05 (1) PC05 (2) PC05 (3) PC05 (4) Lose full credit on problem Lose 25% of full credit on problem Lose 25% of full credit on problem Lose 15% of full credit on problem Page 5 of 13 ENGR 132 Problem 3: Spring 2023 Radio Frequency Spectrum Introduction This problem focuses on your ability to translate an engineering-context flowchart, which has a selection structure, into a MATLAB script, and then use the script to test the selection structure. Follow good programming standards. Submission Individual Gradescope Assignment A07 – Problems 3-4 Deliverables A07Prob3_avSpectrum_login.m Assignment Type Individual Assignment Type Team Team Plan Gradescope Assignment A07 – Team Planning Deliverables Requested information Problem Allocation of radio frequencies for use by government, commercial, and amateur uses is complex and is increasingly important as more and more technologies relying on wireless data transmission become available. The spectrum available is finite and requires user compliance to maintain safety and minimize interferences. The whole spectrum covers frequencies from 0 Hz to 300 GHz. The spectrum is divided into sections, each with various permissions, licensing requirements, and uses. Sections of the spectrum are referred to as “bands” that have a defined frequency range. For example, all AM radio stations broadcast within the 535 – 1705 kHz band. Purdue’s station, WBAA, broadcasts AM on frequency 920.0 within that range. Page 6 of 13 ENGR 132 Spring 2023 Aviation communication and radionavigation rely on priority use of certain radio frequencies on the spectrum. You are working with an industrial engineering team that specializes in aviation ground systems. You must write a program that will display radio band information for aviation systems in the United States. Your program will accept a radio frequency and will display what technology uses that frequency’s band in aviation. Your program will display information for frequencies in these ranges: Band Frequency Range (MHz) Frequency Use 108.150 – 117.975 (inclusive) Aircraft navigation systems 118.000 – 136.975 (inclusive) VHF ground communications 121.475 – 121.525 (inclusive) Emergency frequency band 225.000 – 328.600 and 335.400 – 399.900 (not inclusive) UHF ground communications 328.600 – 335.400 (inclusive) Instrument Landing System glideslope 2700 – 3000 (not inclusive) Airport and weather radars You must write a script that contains one selection structure that will do the following: • Ask the user to input a frequency value in MHz (see Notes before you start), • If the frequency is within one of the given band ranges, display the input frequency value and stated frequency use (see table for uses) that best fits the input frequency value, • If the frequency is not within one of the bands, display a meaningful error message, and • Follow good programming standards in the code and professional communication standards in the text displays. Once you have your code written, run it with the following test cases: Test Case 1 2 3 4 5 6 7 Frequency (MHz) 2950 102.750 335.400 121.500 315.500 225.000 330.150 For each test case, paste your printed display into the RESULTS section of your script as comments. Remember, your results must be a copy of the actual text display with values, not a copy of the code for the print commands. After you finish your test cases, answer this question in the ANALYSIS section of your script. Write your answer as MATLAB comments. 1. Does each condition required by the problem get tested at least one time with the test cases listed above? If no, then list all conditions that are not tested. State a test case that would test an untested path. Base your answer on the information provided in the problem statement. Format your answer following the guidelines in EPS01. Instructions 1. Read through the entire problem statement. 2. With your teammates: develop and document a plan to solve this problem. a. Understand the expectations of the problem. b. Discuss strategies for solving the problem. This can include citing examples from class notes, drawing pictures, outlining a plan using text or pseudocode, etc. DO NOT SHARE CODING SOLUTIONS. Page 7 of 13 ENGR 132 Spring 2023 c. Submit your plan to the team assignment in Gradescope. Work together to make sure it is done correctly. 1. Select 1 team member to submit the plan. 2. Have that team member open the Gradescope assignment for this team plan (see the submission list at the beginning of this problem). 3. In the area for this problem: 4. d. 3. a. Enter the names of your teammates who participated in the planning. b. Enter a brief description of your team’s plan to solve the problem. The plan should be connected to the problem and have at least 2-3 steps. It should not be a detailed explanation of every step necessary to solve the problem. c. If you have image files, etc., that you would prefer to share, then you may add them in the Optional file submission area. Save your results. Add your teammates to the submission. Work together to make sure it is done correctly. 1. Click Submit & View Submission at the bottom of the assignment 2. Add all teammates to the group (Gradescope instruction link) 3. All teammates confirm that you get a submission email and verify that you can see the submission in your Gradescope. 4. You only need to add teammates one time (regardless of the number of problems in the assignment or the number of resubmissions your team makes). Individually: a. Complete your script, run it for each test case to get your results, and paste those results as comments into the script. Answer the analysis question. o b. The team plan is an initial start on the problem. It may not be completely correct, and you may find flaws in the plan once you start coding. You should make any individual changes that are necessary to obtain the best solution. You will be assessed on your individual solution to the problem. Cite any peers you worked with in your script header if their help changed how you decided to solve the problem. • c. Make sure you also completed the rest of the script header. Submit your properly named file(s) to the appropriate problem in the individual Gradescope assignment (see the submission list at the beginning of this problem). o o Submit your deliverables once all your context problems are complete. Click here for help. Do not submit any other files. References https://www.faa.gov/documentLibrary/media/Order/6050_32B_WITH_CHG_1_AND_2_INCORPORATED.pdf Grading LOs: PC05, MAT01, EPS01, MAT07, MAT09 Page 8 of 13 ENGR 132 Spring 2023 Team plan: 1 point Individual assignment point value: 9 points. Partial credit is possible; see the LO table below for details. You must meet the PC05 expectations. If you do not meet these, you will lose additional credit. LO Table (1) (2) (3) (4) (5) (6) (7) (8) PC05 -100% -25% -10% -15% 0 0 0 0 MAT01 0.3 0 0 0 0.3 0.3 0 0 EPS01 0 0 0.3 0.3 0.3 0 0 0 MAT06 0.9 0.9 0.9 0.9 0.9 0 0 0 MAT09 0.9 0.9 0.9 0 0 0 0 0 Grading Process This flowchart outlines how the grader will assess your work for this problem. Page 9 of 13 ENGR 132 Problem 4: Spring 2023 Stormwater Runoff Introduction This problem focuses on your ability to use while loops to answer engineering-based questions. Be sure to follow good programming standards in your script. Submission Individual Gradescope Assignment A07 – Problems 3-4 Deliverables A07Prob4_runoff_login.m Assignment Type Individual Assignment Type Team Team Plan Gradescope Assignment A07 – Team Planning Deliverables Requested information Problem Stormwater runoff is rainwater that cannot be absorbed by the ground during any type of rainfall. Managing stormwater runoff is an important part of planning a community’s water system infrastructure and is complicated due to the significant variability in the frequency and intensity of stormwater amounts. Hundreds of communities in the United States, including West Lafayette, handle stormwater using a type of sewer called a combined sewer system. In these systems, all water that enters municipal drains flows into a collection system that takes the water to a treatment facility. This water contains untreated sewage, industrial wastewater, and stormwater runoff all mixed together. A sewer’s capacity was designed by engineers based on predicted usage, average rainfalls, and forecast community growth and climate changes. Any water over that capacity has to be diverted out of the system, generally into nearby public waterways, before it reaches the treatment facility. As communities grow, the amount of daily water in the sewer rises, which makes the system more likely to overflow during short-term high-water events like rainfall. In West Lafayette, that can mean as little as ¼-inch of rainfall leading to overflow of untreated wastewater directly into the Wabash River. All communities with combined sewer systems must mitigate the possibility of overflow. One way to ease demand on the system is to decrease the amount of water enterering the sewer. When it rains, the permiability of the ground determines how much water will be absorbed and how much will flow into the storm drains. Areas with more buildings, pavement, and built infrastructure produce more runoff than areas with greenspace, lawns, and vegetation. Page 10 of 13 ENGR 132 Spring 2023 You are working with a nearby community’s civil engineering team examining the stormwater runoff effect of converting some paved areas into more permiable ground surfaces. To estimate the runoff on these surfaces, you will use the rational method with the equation 𝑄 = 𝐶𝐼𝐴 (ft3/s), Where Q is the peak runoff flow rate 𝐴 is the drainage area (acres), 𝐶 is the runoff coefficient (unitless), and 𝐼 is the rainfall intensity (in/hr). The units are correct as stated; use these units in your calculations. You can conservatively estimate rainfall intensity using peak rainfall precipitation frequency data for West Lafayette, found in the data file named PF_Intensity_English_PDS.csv. This file shows duration of rainfall in the first column, and each subsequent column shows the maximum predicted rainfall intensity in inches per hour at that duration for various years of recurrance. The annual recurrance interval (ARI) is the average time between rainfall events exceeding the maximum rainfall at a specified duration; ARI for years 1 to 1000 are shown in the data file. ARI is the concept being employed when you hear the phrase “500-year storm”, for example. Your team identified 50 acres of underused paved surfaces located near storm drains and want to convert some amount of that to greenspace. You want the total storm runoff rate for the 50 acres to be less than 200 ft 3/s. You can assume that the paved surfaces have a 0.9 runoff coefficient and that the greenspace replacement will have a runoff coefficient of 0.45. You must write a script that will use indefinite loops to estimate the number of paved acres that need to be transformed to greenspace to meet the required stormwater flow. Your script must do the following: • Import the rainfall intensity data. Refer to course materials for importing data with headers, if needed. • Ask the user what ARI year they want to use to estimate rainfall • If the ARI is not one of the year values in the data file, inform the user and ask them to enter a new value. Continue asking for a new value until a valid year is entered. • Use the input to find the corresponding rainfall intensity at 5-min duration (this allows you to make a conservative estimate). • Converting paved acreage to greenspace acreage in 0.25-acre intervals, find the number of acres that must be converted to greenspace to meet the runoff flow target. • If the amount of greenspace needed to meet the runoff flow rate is greater than the total area available, inform the user with a meaningful message displayed to the Command Window. Otherwise, display the number of acres of needed greenspace along with the estimated runoff flow rate. • This problem does not require any structure nested inside another. Nested structures are taught in future classes of this course and are not needed here. If you choose to use them, they must be correct. Once your code is working, run it for the following test cases. Copy your displays and paste them as comments into the RESULTS section of your script. Test Cases ARI = 1 year ARI = 10 years ARI = 100 years Instructions 1. Read through the entire problem statement. 2. With your teammates: develop and document a plan to solve this problem. a. Understand the expectations of the problem. b. Discuss strategies for solving the problem. This can include citing examples from class notes, drawing pictures, outlining a plan using text or pseudocode, etc. DO NOT SHARE CODING SOLUTIONS. Page 11 of 13 ENGR 132 Spring 2023 c. Submit your plan to the team assignment in Gradescope. Work together to make sure it is done correctly. 1. Select 1 team member to submit the plan. 2. Have that team member open the Gradescope assignment for this team plan (see the submission list at the beginning of this problem). 3. In the area for this problem: 4. d. 3. a. Enter the names of your teammates who participated in the planning. b. Enter a brief description of your team’s plan to solve the problem. The plan should be connected to the problem and have at least 2-3 steps. It should not be a detailed explanation of every step necessary to solve the problem. c. If you have image files, etc., that you would prefer to share, then you may add them in the Optional file submission area. Save your results. Add your teammates to the submission. Work together to make sure it is done correctly. 1. Click Submit & View Submission at the bottom of the assignment 2. Add all teammates to the group (Gradescope instruction link) 3. All teammates confirm that you get a submission email and verify that you can see the submission in your Gradescope. 4. You only need to add teammates one time (regardless of the number of problems in the assignment or the number of resubmissions your team makes). Individually: a. Complete your script, run it for each test case to get your results, and paste those results as comments into the script. o b. The team plan is an initial start on the problem. It may not be completely correct, and you may find flaws in the plan once you start coding. You should make any individual changes that are necessary to obtain the best solution. You will be assessed on your individual solution to the problem. Cite any peers you worked with in your script header if their help changed how you decided to solve the problem. • c. Make sure you also completed the rest of the script header. Submit your properly named file(s) to the appropriate problem in the individual Gradescope assignment (see the submission list at the beginning of this problem). o o Submit your deliverables once all your context problems are complete. Click here for help. Do not submit any other files. References https://www.epa.gov/npdes/combined-sewer-overflows-csos https://iowadot.gov/design/dmanual/04a-05.pdf https://hdsc.nws.noaa.gov/hdsc/pfds/index.html Page 12 of 13 ENGR 132 Spring 2023 Grading LOs: PC05, MAT01, MAT07, MAT08, EPS01, EPS02 Team plan: 1 point Individual assignment point value: 9 points. Partial credit is possible; see the LO table below for details. You must meet the PC05 expectations. If you do not meet these, you will lose additional credit. LO Table (1) (2) (3) (4) (5) (6) (7) (8) PC05 -100% -25% -10% -15% 0 0 0 0 MAT01 0.3 0 0 0 0.3 0 0 0.3 EPS01 0 0 0.3 0.3 0 0 0 0 MAT08 0.45 0.45 0.6 0 0 0 0 0 MAT03 0.3 0.3 0.3 0.3 0.3 0 0 0 MAT06 0.9 0.9 0.9 0.9 0.9 0 0 0 Grading Process Page 13 of 13