1 / 30

CS 100 Introduction to Computing Seminar September 16, 2014

CS 100 Introduction to Computing Seminar September 16, 2014. Let's Work on Some Programs (1). Textbook, page 77, Programming Exercise #2 Develop an algorithm. Let's Work on Some Programs (2). Textbook, page 77, Programming Exercise #2 Develop an algorithm Step 1: Introduce the program

Download Presentation

CS 100 Introduction to Computing Seminar September 16, 2014

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. CS 100 Introduction to Computing Seminar September 16, 2014

  2. Let's Work on Some Programs (1) • Textbook, page 77, Programming Exercise #2 • Develop an algorithm

  3. Let's Work on Some Programs (2) • Textbook, page 77, Programming Exercise #2 • Develop an algorithm • Step 1: Introduce the program • Step 2: Ask for the amount of projected sales • Step 3: Record the user’s response for projected sales. • Step 4: Calculate the projected profit. • Step 5: Provide the user with the projected profit. • Step 6: Stop

  4. Let's Work on Some Programs (3) • Textbook, page 77, Programming Exercise #2 • Develop a flow chart

  5. Let's Work on Some Programs (4) • Textbook, page 77, Programming Exercise #2 • Develop a flow chart • http://www.cs.sunyit.edu/~urbanc/cs_100_sep_16_1.pdf

  6. Let's Work on Some Programs (5) • Textbook, page 77, Programming Exercise #2 • Develop source code

  7. Let's Work on Some Programs (6) • # Create and initialize variables to hold the sales total and the profit • Sales_total = 0.0 • profit = 0.0 • # Step 1: Introduce the program • print ("This program answers Program Exercise #2") • # Step 2: Ask for the amount of projected sales • # Step 3: Record the user’s response for projected sales. • salesTotal = float(input("Enter the projected sales: ")) • # Continued on next slide

  8. Let's Work on Some Programs (7) • # Step 4: Calculate the projected profit. • profit = sales_total * 0.23 • # Step 5: Provide the user with the projected profit. • print ("The projected profit is " , format(profit, '.2f')) • # Step 6: Stop

  9. Let's Work on Some Programs (8) • Textbook, page 77, Programming Exercise #3 • Develop an algorithm

  10. Let's Work on Some Programs (9) • Textbook, page 77, Programming Exercise #3 • Develop an algorithm • # Step 1: Introduce the program • # Step 2: Ask for the amount of square feet of the tract of land. • # Step 3: Record the user’s input for the tract of land. • # Step 4: Calculate the acreage ( tract_size / 43560 ). • # Step 5: Provide the use with the number of acres. • # Step 6: Stop

  11. Let's Work on Some Programs (10) • Textbook, page 77, Programming Exercise #3 • Develop a flow chart

  12. Let's Work on Some Programs (11) • Textbook, page 77, Programming Exercise #3 • Develop a flow chart • http://web.cs.sunyit.edu/~urbanc/cs_100_sep_16_2.pdf

  13. Let's Work on Some Programs (12) • Textbook, page 77, Programming Exercise #3 • Develop source code

  14. Let's Work on Some Programs (13) • # Variables to hold the size of the tract and number of acres. • tract_size = 0.0 • acres = 0.0 • # Step 1: Introduce the program • print ("This program answers Program Exercise #3") • # Step 2: Ask for the square feet in the tract of land. • # Step 3: Record the user’s input for the tract of land. • tract_size = input("Enter the number of square feet in the tract: ")

  15. Let's Work on Some Programs (14) • # Step 4: Calculate the acreage (tract_size / 43560). • acres = float(tract_size) / 43560 • # Step 5: Provide the use with the number of acres. • print ("The size of that tract is" , format(acres , '.2f' ) , "acres.") • # Step 6: Stop

  16. Let's Work on Some Programs (15) • Textbook, page 77, Programming Exercise #4 • Develop an algorithm • Remember: there are only sequential instructions… you cannot use a "loop"

  17. Let's Work on Some Programs (16a) • Textbook, page 77, Programming Exercise #4 • Develop an algorithm • # Step 1: Introduce the program • # Step 2: Ask for the price of the first item • # Step 3: Record the price of the first item • # Step 4: Ask for the price of the second item • # Step 5: Record the price of the second item • # Step 6: Ask for the price of the third item • # Step 7: Record the price of the third item • # Continued on next slide

  18. Let's Work on Some Programs (16b) • Textbook, page 77, Programming Exercise #4 • Develop an algorithm • # Step 8: Ask for the price of the fourth item • # Step 9: Record the price of the fourth item • # Step 10: Ask for the price of the fifth item • # Step 11: Record the price of the fifth item • # Step 12: Calculate the subtotal cost of all 5 items • # Step 13: Calculate the sales tax amount (subtotal * tax rate) • # Step 14: Calculate the total (subtotal + sales tax amount) • # Step 15: Communicate the subtotal, sales tax, and total values • # Step 16: Stop

  19. Let's Work on Some Programs (17) • Textbook, page 77, Programming Exercise #4 • Develop a flow chart

  20. Let's Work on Some Programs (18) • Textbook, page 77, Programming Exercise #4 • Develop a flow chart • http://web.cs.sunyit.edu/~urbanc/cs_100_sep_16_3.pdf

  21. Let's Work on Some Programs (19) • Textbook, page 77, Programming Exercise #4 • Develop source code

  22. Let's Work on Some Programs (20) • Textbook, page 77, Programming Exercise #4 • Develop source code • http://web.cs.sunyit.edu/~urbanc/cs_100_sep_16_c1.html

  23. Let's Work on Some Programs (21) • Textbook, page 77, Programming Exercise #10 • Develop an algorithm

  24. Let's Work on Some Programs (22) • Textbook, page 77, Programming Exercise #10 • Develop an algorithm • # Step 1: Introduce the program • # Step 2: Ask the user for the desired number of cookies • # Step 3: Record the user’s input for the number of cookies • # Step 4: Calculate the cups of sugar needed • # Step 5: Calculate the cups of butter needed • # Step 6: Calculate the cups of flour

  25. Let's Work on Some Programs (23) • Textbook, page 77, Programming Exercise #10 • Develop an algorithm • # Step 7, 8, and 9: Communicate the amount of butter, sugar, • # and flour needed to make the specified number of cookies. • # Step 10: Stop

  26. Let's Work on Some Programs (23) • Textbook, page 77, Programming Exercise #10 • Develop a flow chart

  27. Let's Work on Some Programs (24) • Textbook, page 77, Programming Exercise #10 • Develop a flow chart • http://web.cs.sunyit.edu/~urbanc/cs_100_sep_16_4.pdf

  28. Let's Work on Some Programs (25) • Textbook, page 77, Programming Exercise #4 • Develop source code

  29. Let's Work on Some Programs (26) • Textbook, page 77, Programming Exercise #4 • Develop source code • http://web.cs.sunyit.edu/~urbanc/cs_100_sep_16_c2.html

  30. Thursday: Practice Exam • Chapters 1 and 2 and anything/everything covered in class

More Related