Reread question and fixed tasks

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

View File

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