In: Computer Science
The Harrison Group Life Insurance company computes annual policy premiums base on the age the customer turns in the current calendar year. The premium is computed by taking the decade of the customer’s age, adding 15 to it, and multiplying by 20. For example, a 34 year old would pay $360, which is calculated by adding the decades(3) to 15, and then multiplying by 20. Write an application that prompts a user for the current year(yyyy) and a birth year(yyyy). A customer must be at least 18 in the current year to purchase life insurance. The program should allow five customers’ annual premiums to be calculated without exiting. Once the fifth customer’s premium is computed, the program should display the following message and exit: Thanks for using our services.
The following must be included in the program: Use Python
Functions:
The program must contain a function, calcAge, that calculates and returns the customer’s age. This function takes the birth year and current year as parameters
Include a second function, calcPremium, which calculates and displays the annual premium. This function takes the customer’s age as parameter.
Validation:
If the customer’s age is less than 18, the program should not compute the annual premium. The following message must should be displayed: Sorry, you are not old enough to purchase life insurance
def calcAge(birthYear, currentYear):
return currentYear - birthYear
def calcPermium(age):
decades = age / 10
premium = (decades + 15 ) * 20
return premium
for i in range(5):
birthYear = int(input("Enter birth year: \n"))
currentYear = int(input("Enter current year: \n"))
age = calcAge(birthYear, currentYear)
if age < 18:
print("Sorry, you are not old enough to purchase life insurance")
else:
premium = calcPermium(age)
print("Premium to be paid is", premium)
print("Thanks for using our services.")