CIS 111 Selection

Objectives

  • Design simple algorithms using selection
  • Create a flowchart that represents an algorithm that uses selection
  • Create programs that implement algorithms

Overview

For each of the programming projects listed, write a Python program to solve the problem. The first problem also requires that you create a flowchart. The flowchart must be neat and professional, drawn with either a flowcharting template or a computer application. The source code listings for these programs, and all others due in this course, must include comments at the beginning of the source code which contain your name, the course, the date, and the assignment number. It is considered cheating to copy work. Problems may be discussed, but not copied.

Both programs must calculate the value that is output at the end. Just printing a hardcoded number in the source code indicates that your program has no real functionality. Make sure that your programs are displaying the value of a variable that has been used to store calculations. If you don't know what that means, then ask.

Program #1 (of 2)

(26 pts) Write a program that will calculate discounts. The program should ask the user for three bits of information: item ID, price, and quantity. The program should then print out a bill. The first line should be a subtotal (quantity multiplied by price), the second line should be the discount (no discount if quantity is less than 144, 10% of subtotal if quantity is 144 to 999, and 20% of subtotal if quantity is 1000 or more. Format the output so it lines up nicely in columns and the numbers have two digits after the decimal point. Formatting output will be discussed in class and will appear in at least one demonstration program.

This program will calculate volume discounts Enter the item ID: 56RT Enter the price: 34.57 Enter the quantity: 3 Subtotal: 103.71 Discount: 0.00 ------- Total: 103.71 This program will calculate volume discounts Enter the item ID: gtr4 Enter the price: 67.54 Enter the quantity: 144 Subtotal: 9725.76 Discount: 972.58 ------- Total: 8753.18 This program will calculate volume discounts Enter the item ID: TM75X Enter the price: .57 Enter the quantity: 1500 Subtotal: 855.00 Discount: 171.00 ------- Total: 684.00

Program #2 (of 2)

(14 pts) Your job is to create a menu for a computerized terminal in a new "cyber-vegetarian" restaurant. Your program should display a menu of mouth-watering choices. When the user selects a choice, a custom message should be printed depending upon which choice the user made. The listing below shows one sample run of the program. After the sample run is a listing of all six custom messages. A flowchart for this program is available.

Please choose the item you would like for lunch 1. Cheese Pizza 2. Gardenburger 3. Vegetable Fajitas 4. Provolone, Lettuce, and Tomato Sandwich 5. Spaghetti Your choice (1-5): 1 The pizza is an excellent choice. All six custom messages: The pizza is an excellent choice. Fries are available for just $2.00! The fajitas will be served sizzling hot. Our PLT is the ultimate summer snack. Our spaghetti bowl is bottomless (all you can eat). You chose an invalid number

Rubric

  1. Problem #1 is worth 26 points:
    • 12 points for a correct, professional (not hand-drawn) flowchart
    • 12 points for correct operation and I/O that matches the sample
    • 2 points for proper documentation comments and correctly following coding conventions (indentation, naming rules, etc.)
  2. Problem #2 is worth 14 points:
    • 12 points for correct operation and I/O that matches the sample
    • 2 points for proper documentation comments and for correctly following coding conventions (indentation, naming rules, etc.)