#====================================================================== #Program: Software Cost Calculation #Author: William #Date: 4.18.15 #Dev Env: Python #Description: This program asks user for the total package units being purchased to then determine what(if any) #discount bracket the purchase qualifies for. Following showing the discount the total cost after discount should be shown. #====================================================================== #///////ALGORITHIM START///// #1 get input from user in form of number of total packages being purchased #2 perform decision module to find amount of discount #3 Discount Options #10-19 = discount 20% #20-49 = discount 30% #50-99 = discount 40% #100 = discount 50% #4 Display amount of discount (if there is one) #5 display total amount of purchase after the discount #///////ALGORITHIM END///// #///////PSEUDOCODE START///// #///////PSEUDOCODE END/////// #///////MAIN PROGRAM START///// #getInput Module quantity = 0 quantity = float(raw_input("Please enter the number of software packages being purchased.")) #print("The number of software packages purchased is ", quantity) #//////end input # /////// DISCOUNT OPTION DECISION AND CALCULATION START cost=99 discount=0 baseCost=0 totalDiscount=0 totalCost=0 #///////sample multiple param start #if (number < 1 or number > 10): # print "error" #///////sample multiple param start #////////testing variable working so far #print("Was your number ", quantity, "?") #print("i'm showing initial value set", cost) #print("i'm showing initial value set", discount) #print("i'm showing initial value set", totalDiscount) #///////////////////testing variable working so far #///////50% discount start if (quantity >99): discount = 0.50 baseCost = quantity * cost totalDiscount = (quantity * cost) * discount totalCost = baseCost - totalDiscount print("The discount is 50% and purchase price is $", "%.2f" % totalCost) #///////50% discount end #///////40% discount start elif (quantity >= 49 and quantity < 100): discount = 0.40 baseCost = quantity * cost totalDiscount = (quantity * cost) * discount totalCost = baseCost - totalDiscount print("The discount is 40% and purchase price is $", "%.2f" % totalCost) #///////40% discount end #///////30% discount start elif (quantity >= 19 and quantity < 50): discount = 0.30 baseCost = quantity * cost totalDiscount = (quantity * cost) * discount totalCost = baseCost - totalDiscount print("The discount is 30% and purchase price is $", "%.2f" % totalCost) #///////30% discount end #///////20% discount start # print(baseCost) was verifying variable functioning # print("%.2f" % 3.14159) testing using only two decimal places elif (quantity >= 9 and quantity < 20): discount = 0.20 baseCost = quantity * cost totalDiscount = (quantity * cost) * discount totalCost = baseCost - totalDiscount print("The discount is 20% and purchase price is $", "%.2f" % totalCost) #///////20% discount end #///////no discount start else: discount = 0 totalDiscount = (quantity * cost) * discount baseCost = quantity * cost totalDiscount = (quantity * cost) * discount totalCost = baseCost - totalDiscount print("There is no discount for this quantity and the purchase price is $", "%.2f" % totalCost) #///////no discount end # /////// DISCOUNT OPTION DECISION AND CALCULATION START #////////testing variable working so far #print("i'm showing final value set for cost $", cost) #print("i'm showing final value set for discount", discount) #print("i'm showing final value set for totaldiscount $", totalDiscount) #///////////////////testing variable working so far #///////////DISPLAY MODULE STARTS #///////////DISPLAY MODULE STARTS #///////MAIN PROGRAM END///////
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question