Reread question and fixed tasks

haskell
Oystein Kristoffer Tveit 2020-09-07 14:53:57 +02:00
parent 0919e6e884
commit 064fe2009e
2 changed files with 16 additions and 13 deletions

View File

@ -8,14 +8,14 @@ def boolInput(question):
except AssertionError:
print('Skriv in J eller N\n')
def discountBranch():
choseDiscount = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
print('Takk for pengene, god reise!' if choseDiscount else 'Da tilbyr vi fullpris: 440,-')
def miniPriceBranch():
choseMiniPrice = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
print('Takk for pengene, god reise!' if choseMiniPrice else 'Da tilbyr vi fullpris: 440,-')
daysToTrip = int(input('Dager til du skal reise? '))
if daysToTrip >= 14:
discountBranch()
miniPriceBranch()
else:
print('For sent for minipris; fullpris 440,-')

View File

@ -8,6 +8,13 @@ def boolInput(question):
except AssertionError:
print('Skriv in J eller N\n')
def miniPriceBranch():
choseMiniPrice = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
if choseMiniPrice:
print('Takk for pengene, god reise!')
else:
normalBranch()
def evalDiscountPercent():
age = int(input('Skriv inn din alder: '))
if age < 16:
@ -18,18 +25,14 @@ def evalDiscountPercent():
hasSpecialSocialStatus = boolInput('Er du student eller militær (J/N)?')
return 25 if hasSpecialSocialStatus else 0
def discountBranch():
choseDiscount = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
if choseDiscount:
discountPercent = evalDiscountPercent()
print(f'Prisen på biletten blir: {440 - 440 * discountPercent/100}')
else:
print('Da tilbyr vi fullpris: 440,-')
def normalBranch():
discountPercent = evalDiscountPercent()
print(f'Prisen på biletten blir: {440 - 440 * discountPercent/100}')
daysToTrip = int(input('Dager til du skal reise? '))
if daysToTrip >= 14:
discountBranch()
miniPriceBranch()
else:
print('For sent for minipris; fullpris 440,-')
normalBranch()