Question: PLEASE HELP: CODE THIS IN PAYTHON LANGUAGE According to the USDA, February price for a dozen eggs in the Metropolitan DC, MD, VA area was
PLEASE HELP: CODE THIS IN PAYTHON LANGUAGE
According to the USDA, February price for a dozen eggs in the Metropolitan DC, MD, VA area was as follows: Conventional Eggs $4.30 Organic Eggs $6.50 When you buy a dozen eggs in Prince William County, VA, then you also pay the following tax rates: State of Virginia 4.3% Prince William County 1% Prince William County Special 0.7% Write a program that does the following: Present a menu to the user asking them which type of egg they want to purchase and give them the option to quit. This is a sentinel value loop. Please enter the type of egg you want to purchase: C for Conventional Eggs per Dozen: 4.34 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program
Use a while loop to validate the menu choices as either C or O or Q and let the user know if they entered an invalid menu choice. Then ask the user to input the menu choice again if it was invalid. Ask the user to input their credit card number. Then validate it to make sure that it is either 15 or 16 characters in length and contains only digits. Ask the user for the quantity of eggs to purchase as input. Validate the quantity to make sure that it is at least 1. Set the price and description for the egg purchased using an if statement. Calculate the sale amount before taxes by multiplying the price by the quantity. Calculate the Virginia Sales Tax by multiplying the sale amount before taxes by the Virginia Tax Rate. Calculate the Prince William County Sales Tax by multiplying the sale amount before taxes by the Prince William County Tax Rate. Calculate the Prince William County Special Sales Tax by multiplying the sale amount before taxes by the Prince William County Special Sales Tax Rate. (Remember if you use 4.3, 1.0, and .7 as the tax rates, then you need to divide by 100 for the tax to calculate correctly; otherwise, you will over tax the customer.) After calculating the sales tax amounts, you will need to add the 3 tax amounts to the sale amount before taxes in order to obtain the sale amount after taxes. Then display the receipt to the customer that shows the type of egg purchase, price, qty, sales amount before taxes, VA Sales Tax amount, PWC Sales Tax amount, PWC Special Sales Tax amount, sales amount after taxes. After displaying the receipt to the customer, display the menu asking them which type of egg they want to purchase and give them the option to quit. This will be the ending part of the sentinel value loop.
To assist you with understanding the problem, here is how the program will run including at least 1 invalid choice for the type of egg, and 1 invalid choice for the quantity of egg purchased. Menu prompts and invalid messages are shown here in addition to the correct formatting for the receipt. You will need to use print formatting to control the decimal places shown to the user. Input is shown in red. Submit your eggs.py code in Canvas for Programming Assignment 1. Please enter the type of egg you want to purchase: C for Conventional Eggs per Dozen: 4.340 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program a Invalid Choice. Please enter one of the following: C for Conventional Eggs per Dozen: 4.34 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program z Invalid Choice. Please enter one of the following: C for Conventional Eggs per Dozen: 4.34 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program c Enter your credit or debit card number: 12345678912345 Invalid. Credit card # must be either 15 or 16 digits in length: Enter your credit or debit card number: 123456789a12345 Invalid. Please enter digits (0-9): Enter your credit or debit card number: 12345678aaaaaa Invalid. Credit card # must be either 15 or 16 digits in length: Invalid. Please enter digits (0-9): Enter your credit or debit card number: 123456789123456 Enter the quantity of cartons of eggs to purchase: -1 Invalid entry. You must purchase at least 1 carton: 0 Invalid entry. You must purchase at least 1 carton: 2 ---------------------Receipt------------------- Eggs Purchased Conventional Eggs Price per Carton 4.34 Cartons Purchased 2 Total Before Taxes 8.68 VA Sales Tax 0.37 PWC Sales Tax 0.09 PWC Special Sales Tax 0.06 Total After Taxes 9.20
Thanks for purchasing eggs, do you want some more? Please enter the type of egg you want to purchase: C for Conventional Eggs per Dozen: 4.340 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program o Enter your credit or debit card number: 1234567891234567 Enter the quantity of cartons of eggs to purchase: 1 ---------------------Receipt------------------- Eggs Purchased Organic Eggs Price per Carton 6.50 Cartons Purchased 1 Total Before Taxes 6.50 VA Sales Tax 0.28 PWC Sales Tax 0.07 PWC Special Sales Tax 0.05 Total After Taxes 6.89 ----------------------------------------------- Thanks for purchasing eggs, do you want some more? Please enter the type of egg you want to purchase: C for Conventional Eggs per Dozen: 4.340 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program z Invalid Choice. Please enter one of the following: C for Conventional Eggs per Dozen: 4.34 O for Organic Eggs per Dozen: 6.50 Q to Quit the Program q Thanks for purchasing eggs, go scramble!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
