diff --git a/Exercise 2/8 - Billettpriser og rabatter/8b.py b/Exercise 2/8 - Billettpriser og rabatter/8b.py index 91e92b2..db30de7 100644 --- a/Exercise 2/8 - Billettpriser og rabatter/8b.py +++ b/Exercise 2/8 - Billettpriser og rabatter/8b.py @@ -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,-') \ No newline at end of file diff --git a/Exercise 2/8 - Billettpriser og rabatter/8c.py b/Exercise 2/8 - Billettpriser og rabatter/8c.py index fc3d2ff..7a8b1b6 100644 --- a/Exercise 2/8 - Billettpriser og rabatter/8c.py +++ b/Exercise 2/8 - Billettpriser og rabatter/8c.py @@ -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,-') \ No newline at end of file + normalBranch() \ No newline at end of file