1 / 9

Lesson 5 Homework: Logic and Planning Tools A step by step solution guide

Lesson 5 Homework: Logic and Planning Tools A step by step solution guide. Lesson 5 IPO / Algorithm Assignment Solution Guide. Complete this assignment by applying the Problem Solving Method . Tasks: Calculate and output the average of the following marks: 80%, 55%, 75%, 93%.

audra
Download Presentation

Lesson 5 Homework: Logic and Planning Tools A step by step solution guide

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lesson 5 Homework: Logic and Planning ToolsA step by step solution guide

  2. Lesson 5 IPO / Algorithm Assignment Solution Guide • Complete this assignment by applying the Problem Solving Method. • Tasks: • Calculate and output the average of the following marks: 80%, 55%, 75%, 93%. • 2. You are given $265.00. Calculate and output the minimum number of 100, 50, 20, 10, and 5 dollar bills you receive. • 3. Calculate and output the amount of HST (13%) charged on an • item, as well as the total cost of the item after taxes. (not included in this guide) • Required: • a) a statement of the problem; • b) a completed Input-Processing-Output Chart; and • c) the problem stated in Pseudo-Code; • For demonstration purposes a final solution in Javascript code will • be given in this solution guide.

  3. Lesson 5 IPO / Algorithm Assignment Solution Guide Task 1: Calculate and output the average of the following marks: 80%, 55%, 75%, 93%. IPO Solution: INPUT PROCESSING OUTPUT Enter 4 marks total marks = mark1+mark2... Average = total marks / 4 Average Pseudocode: • Enter 4 marks • Add marks together • Calculate average (divide sum of marks by number or marks) • Output average Go to next slide for Javascript “translation”…

  4. Lesson 5 IPO / Algorithm Assignment Solution Guide Javascript “translation” following pseudocode (<script> segment only): Task 1: Calculate and output the average of the following marks: 80%, 55%, 75%, 93%. // pseudocode: Enter 4 marks var mark1=80; var mark2=55; var mark3=75; var mark4=93 // pseudocode: Add marks together TotalMarks=mark1+mark2+mark3+mark4 // pseudocode: Calculate average (divide sum of marks by number or marks) average=TotalMarks/4 // pseudocode: Output Average document.write("The average of "+mark1+" , "+mark2+" , "+mark3+" , "+mark4+" is: "+average) Go on to Task 2 solution…

  5. Lesson 5 IPO / Algorithm Assignment Solution Guide Task 2: You are given $265.00. Calculate and output the minimum number of 100, 50, 20, 10, and 5 dollar bills you receive. IPO Solution: INPUT PROCESSING OUTPUT Enter amount($265) # of 100's=amount / 100 (parse or floor) remaining $ =amount-(# of 100's x 100)  # of 100's & remaining $ # of 50's=amount / 50 (parse or floor) remaining $ =amount-(# of 50's x 50)  # of 50's & remaining $ repeat for 20,10 & 5 until 0 $ left • # of 20,10 & 5s and remaining $ Go to next slide for pseudocode solution…

  6. Lesson 5 IPO / Algorithm Assignment Solution Guide Task 2: You are given $265.00. Calculate and output the minimum number of 100, 50, 20, 10, and 5 dollar bills you receive. Pseudocode: a. input amount b. calculate # of 100's (amount divided by 100), parse or floor to round down c. calculate remaining amount by subtracting from total amount of 100's possible d. print number of 100's and remaining $ e. repeat steps b, c and d for 50, 20, 10 and 5 dollars Go to next slide for Javascript “translation”…

  7. Lesson 5 IPO / Algorithm Assignment Solution Guide Javascript “translation” following pseudocode (<script> segment only): Task 2: You are given $265.00. Calculate and output the minimum number of 100, 50, 20, 10, and 5 dollar bills you receive. // pseudocode: Input Amount var amount=265 // pseudocode: calculate # of 100's (amount / 100), parse to remove decimal part var N_of_100=parseInt(amount/100) // pseudocode: calculate remaining amount (subtract amount from 100's possible) var amount=amount-(N_of_100*100) // pseudocode: print number of 100's and remaining $ document.write("Number of 100's ====> [ "+N_of_100+" ] ====> [ $"+amount+" ] remaining<br>") // and repeat for 50’s, 20’s, 10’s and 5’s… var N_of_50=parseInt(amount/50) var amount=amount-(N_of_50*50) document.write("<br>Number of 50's ====> [ "+N_of_50+" ] ====> [ $"+amount+" ] remaining<br>") var N_of_20=parseInt(amount/20) var amount=amount-(N_of_20*20) document.write("<br>Number of 20's ====> [ "+N_of_20+" ] ====> [ $"+amount+" ] remaining<br>") var N_of_10=parseInt(amount/10) var amount=amount-(N_of_10*10) document.write("<br>Number of 10's ====> [ "+N_of_10+" ] ====> [ $"+amount+" ] remaining<br>") var N_of_5=parseInt(amount/5) var amount=amount-(N_of_5*5) document.write("<br>Number of 5's ====> [ "+N_of_5+" ] ====> [ $"+amount+" ] remaining<br>") Go to next Slide to TRACE variables…

  8. Lesson 5 IPO / Algorithm Assignment Solution Guide Task 2 <script> segment revisited: Trace the Variables 265 var amount=265 var N_of_100=parseInt(amount/100) var amount=amount-(N_of_100*100) document.write("Number of 100's ====> [ "+N_of_100+" ] ====> [ $"+amount+" ] remaining<br>") 2.65 265 2 2 2 265 - 200 65 2 65 Result in Browser:

  9. Lesson 5 IPO / Algorithm Assignment Solution Guide End of IPO Solution Guide Go Back to Task 1 Go Back to Task 2 Go to Variable Trace Example Go to www.westhillci.ca

More Related