Created
February 16, 2017 19:47
-
-
Save Spockky/de64f08fbbb413586a1f33316df28171 to your computer and use it in GitHub Desktop.
Python program that calculates the final price of an item after asking the user if there is an in-store discount and if they have a coupon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# module calculate_store_discount() is where I am having issues. I also tried linking original_price() | |
# to calculate_store_discount() so I wouldn't have to have the user re-enter. The in_store_discount() | |
# and calculate_store_discount() are going to be 'duplicated' with variables relating to the | |
# coupon inputs and calculation ( calculate_coupon(), coupon_discount() ). Another module is going to | |
# be created to calculate the final price after I figure out what my hang up is with the math. | |
def main(): | |
welcome = welcome_message() | |
store_discount = in_store_discount() | |
def welcome_message(): | |
print "Hello! Calculate the final price of an item with an in-store sale and " | |
print "a coupon if they are available. First input the original price (ex. 1.00) " | |
print " follwed by the in-store discount (ex. .20), and the coupon amount. " | |
def original_item_price(): | |
original_price = 0.0 | |
original_price = float(input("What is the original price of the item?")) | |
return original_price | |
def in_store_discount(): | |
store_discount_choice = 0.0 | |
original_price = 0.0 | |
store_discount_percentage = 0.0 | |
orig_price = original_item_price() | |
store_discount_choice = int(input("Is there an in-store discount? Enter 1 for Yes, 2 for No.")) | |
if store_discount_choice == 1: | |
calculate_store_discount() | |
elif store_discount_choice == 2: | |
original_price_remains() | |
def calculate_store_discount(): | |
original_price = 0.0 | |
in_store_discount = 0.0 | |
discount_amount = 0.0 | |
final_store_discount = 0.0 | |
original_price = int(input("Re-Enter the original price.")) | |
in_store_discount = int(input("What is the in_store discount? (ex. .20)")) | |
discount_amount = original_price * in_store_discount | |
final_store_discount = original_price - discount_amount | |
print "The in_store savings amount is ", discount_amount | |
print "Your new price is ", final_store_discount | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment