In: Computer Science
def main():
FISH_TACOS = 3.00
TACOS_AL_CARBON = 4.00
DON_PEDRO_SPECIAL = 9.00
PAPAS_CON_CHORIZO = 5.00
CARNE_ASADA_TACOS = 1.75
SALES_TAX = 0.06
DISCOUNT = 0.1
costofFish_Tacos=.0
costofTacos_Al_Carbon=.0
costofDon_Pedro_Special=.0
costofPapas_Con_Chorizo=.0
costofCarne_Asada_Tacos=.0
numofFish_Tacos=.0
numofTacos_Al_Carbon=.0
numofDon_Pedro_Special=.0
numofPapas_Con_Chorizo=.0
numofCarne_Asada_Tacos=.0
subTotal=.0
AmountGiven=.0
cash = .0
change = .0
OrigTotal=.0
WithTax=.0
TotalOrder = .0
AmountGiven = .0
numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos= getInput()
getOutput(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos)
subTotal = calcOrder(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos)
WithTax = CalcTax(subTotal,SALES_TAX)
disTotal(subTotal, WithTax)
CalcCash(OrigTotal, cash, change)
def getInput():
numofFish_Tacos = int(input("How many Fish Tacos do you want?"))
numofTacos_Al_Carbon = int(input("How many Tacos Al Carbon do you want?"))
numofDon_Pedro_Special = int(input("How many Don Pedro Special do you want?"))
numofPapas_Con_Chorizo = int(input("How many Paps Con Chorizo do you want?"))
numofCarne_Asada_Tacos = int(input("How many Carne Asada Tacos do you want?"))
return numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos
def getOutput(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos):
costofFish_Tacos = FISH_TACOS * numofFish_Tacos
costofTacos_Al_Carbon = TACOS_AL_CARBON * numofTacos_Al_Carbon
costofDon_Pedro_Special = DON_PEDRO_SPECIAL * numofDon_Pedro_Special
costofPapas_Con_Chorizo = PAPAS_CON_CHORIZO * numofPapas_Con_Chorizo
costofCarne_Asada_Tacos = CARNE_ASADA_TACOS * numofCarne_Asada_Tacos
print(numofFish_Tacos, "Fish Tacos", "each at $", FISH_TACOS, "Costs $", costofFish_Tacos)
print(numofTacos_Al_Carbon, "Tacos Al Carbon", "each at $", TACOS_AL_CARBON, "Costs $", costofTacos_Al_Carbon)
print(numofDon_Pedro_Special, "Don Pedro Special", "each at $", DON_PEDRO_SPECIAL, "Costs $",
costofDon_Pedro_Special)
print(numofPapas_Con_Chorizo, "Papas Con Chorizo", "each at $", PAPAS_CON_CHORIZO, "Costs $",
costofPapas_Con_Chorizo)
print(numofCarne_Asada_Tacos, "Carne Asada Tacos", "each at $", CARNE_ASADA_TACOS, "Costs $",
costofCarne_Asada_Tacos)
return FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos
def calcOrder(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos):
subTotal = ((numofFish_Tacos * FISH_TACOS) + (numofTacos_Al_Carbon * TACOS_AL_CARBON) + (numofDon_Pedro_Special * DON_PEDRO_SPECIAL) + (numofPapas_Con_Chorizo * PAPAS_CON_CHORIZO) + (numofCarne_Asada_Tacos * CARNE_ASADA_TACOS))
print("Sub Total $", subTotal)
print('subTotal:', subTotal)
return subTotal
def CalcTax(subTotal,SALES_TAX):
WithTax = (SALES_TAX * subTotal)
print("Total of the order with sales tax is:$ ", WithTax)
print('With Tax:', WithTax)
return WithTax
def disTotal(subTotal,WithTax):
OrigTotal = WithTax + subTotal
print('Total now is',OrigTotal)
return OrigTotal
def CalcCash(OrigTotal, cash, change):
OrigTotal = str(OrigTotal)
cash = input('This is how much you owe'+OrigTotal+'Please pay in cash: ')
OrigTotal = str(OrigTotal)
print('Amount received: $', cash)
OrigTotal = float(OrigTotal)
cash =float(cash)
change = cash - OrigTotal
if change < 0:
change=str(change)
addChange = input('You still owe me $'+ change + 'Please pay in cash')
change=float(change)
addChange=float(addChange)
change= addChange + change
print('Costumer change is: $', change)
print('------------------------------')
main()
Not calculating this part need help asap
def CalcCash(OrigTotal, cash, change):
OrigTotal = str(OrigTotal)
cash = input('This is how much you owe'+OrigTotal+'Please pay in cash: ')
OrigTotal = str(OrigTotal)
print('Amount received: $', cash)
OrigTotal = float(OrigTotal)
cash =float(cash)
change = cash - OrigTotal
if change < 0:
change=str(change)
addChange = input('You still owe me $'+ change + 'Please pay in cash')
change=float(change)
addChange=float(addChange)
change= addChange + change
print('Costumer change is: $', change)
print('------------------------------')
You are not using returned value from disTotal method. This is why the CalcCash method is getting the value of OrigTotal as 0.
Replace your main() method with this code: (for indentation please refer to screenshot)
def main():
FISH_TACOS = 3.00
TACOS_AL_CARBON = 4.00
DON_PEDRO_SPECIAL = 9.00
PAPAS_CON_CHORIZO = 5.00
CARNE_ASADA_TACOS = 1.75
SALES_TAX = 0.06
DISCOUNT = 0.1
costofFish_Tacos=.0
costofTacos_Al_Carbon=.0
costofDon_Pedro_Special=.0
costofPapas_Con_Chorizo=.0
costofCarne_Asada_Tacos=.0
numofFish_Tacos=.0
numofTacos_Al_Carbon=.0
numofDon_Pedro_Special=.0
numofPapas_Con_Chorizo=.0
numofCarne_Asada_Tacos=.0
subTotal=.0
AmountGiven=.0
cash = .0
change = .0
OrigTotal=.0
WithTax=.0
TotalOrder = .0
AmountGiven = .0
numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos= getInput()
getOutput(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos)
subTotal = calcOrder(FISH_TACOS,TACOS_AL_CARBON,DON_PEDRO_SPECIAL,PAPAS_CON_CHORIZO,CARNE_ASADA_TACOS,numofFish_Tacos,numofTacos_Al_Carbon,numofDon_Pedro_Special,numofPapas_Con_Chorizo,numofCarne_Asada_Tacos)
WithTax = CalcTax(subTotal,SALES_TAX)
OrigTotal = disTotal(subTotal, WithTax) # here storing OrigTotal returned from disTotal
CalcCash(OrigTotal, cash, change)
Output:

Screenshot:

* Please see line 32, this is where I made changes.