Use of procedures, parameter passing, block structures, data types, arrays, abstract data structures, conditional control, iterative and recursive processes, and input/output in programming solutions to a variety of problems. Prerequisite: None.

Lab 2 - Introduction to Operators and Conditionals - (50 points)



Due date: 2/13/2019 at 11:59pm

Objectives



  • Learn about variables
  • Familiarize yourself with operators in Python
  • Apply conditional operators in Python

Part 1 - Hot dog calculator (20 points)



Assume that hot dogs come in packages of 10, and hot dog buns come in packages of 8. Write a program (hotdog.py) that calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a cookout, with the minimum amount of leftovers. The program should ask the user for the number of people attending the cookout and the number of hot dogs each person will be given. The program should display the following details:

  • The minimum number of packages of hot dogs required
  • The minimum number of packages of hot dog buns required
  • The number of hot dogs that will be left over
  • The number of hot dog buns that will be left over

Part 2 - Shopping Cart Program (30 points)



Write a Python program (shoppingcart.py) that does the following:

  • Print a message that says "Welcome to the Healthy Fruits Shop!"
  • Print "Please enter how many pounds of raspberries you would like to buy ($1.75 per pound):". Store the customer entered value in a variable.
  • Print "Please enter how many pounds of strawberries you would like to buy ($1.25 per pound):". Store the customer entered value in a variable.
  • Print "Please enter how many apples you would like to buy ($0.5 per apple):". Store the customer entered value in a variable.
  • Print "Please enter how many mangoes you would like to buy ($1.75 per mango):". Store the customer entered value in a variable.
  • Compute and display the total owed by the customer.
  • Now ask the customer to enter an amount to pay for the fruits and vegetables and store that value in a variable.
  • Check to see if the customer entered amount is greater than the amount owed to the store. If not, show a message to the customer and ask them to enter more money. Add the entered money to the previously entered money.
  • Compute and Display the change owed to the customer.
  • Now compute the number of $5, $1, quarters, dimes, nickels, and pennies required to return that change to the customer.
  • Display only the amount of change that must be disbursed to the customer. Here are some test cases:

    • If the total is $14.75 and the customer gives you $20, then your program must display "The change is $5.25. Give the customer 1 $5 note, and 1 quarter."
    • If the total is $33.35 and the customer gives you $40, then your program must display "The change is $6.65. Give the customer 1 $5 note, 1 $1 note, 2 quarters, 1 dime, and 1 nickel.

Submitting the lab using Canvas



Please create a zip file of the lab2 folder and submit it on Canvas. The folder must contain the following files:

  • hotdog.py
  • shoppingcart.py
  • README