Question
You have been tasked to construct a program that will prepare automobile liability insurance estimates for customers. The input consists of: The name of the
You have been tasked to construct a program that will prepare automobile liability insurance estimates for customers. The input consists of: The name of the customer The age of the customer The number of traffic violations
Based on this information you will determine their status as a driver, following these guidelines:
Number of Violations Risk Code Risk Type 4 or More 1 High 3 2 Moderate 2 2 Moderate 1 3 Low 0 4 No
More than 4 tickets indicate a Code 1 driver, which is High Risk. Code 2 Drivers who have either 2 or 3 tickets, are considered Moderate Risk drivers. Any driver with one ticket is deemed Code 3, and considered Low Risk. Drivers without any tickets are considered Code 4, which is No Risk. Based upon this classification you can then give them the appropriate quote.
Pricing of Insurance: Age Number of Tickets Risk Code Price Under 25 4 or more 1 $480.00 25 or older 4 or more 1 $410.00 Under 25 3 2 $450.00 25 or older 3 2 $390.00 Under 25 2 2 $405.00 25 or older 2 2 $365.00 Under 25 1 3 $380.00 25 or older 1 3 $315.00 Under 25 0 4 $325.00 25 or older 0 4 $275.00
Sample output line follows (Items underlined are variable values): Customer Name, as a ---- risk driver, your insurance will cost -----.
You are to account for invalid input. Drivers must be between the ages of 16 and 105. Number of traffic violations cannot be less than 0. Display only the message Invalid Entry in either case.
I need a loop to allow the program to run multiple times as well as a way to validate age. Here is what I have so far:
risk_type1 = 'high' risk_type2 = 'moderate' risk_type3 = 'low' risk_type4 = 'no' traffic_violations = 0 risk_code = 0
age = 0 number_tickets = 0
#define main def main(): #geting name and age and ensure user enter that right age group new_quote = 'y' while new_quote == 'y' or new_quote == 'Y': name = input("Enter the name of the customer: ") age = int(input("Enter the age of the customer: "))
if age < 16 and age > 106: print("customer cannot be under 16 or over 105") else: age = int( input("Please enter a valid customer age : ")) #getng number or tickets and traffic violation traffic_violations = int(input("Enter the number of traffic violations: ")) number_tickets = int(input("Enter the number of tickets: "))
risk = calc_Risk(traffic_violations, risk_type1 , risk_type2 , risk_type3 , risk_type4) insurance_price = calcInsurance(age, number_tickets,risk_code) display_qoute(name,risk_type, insurance_price) new_quote = input("would you like to do another quote? Y or N : ") # calculating the risk code and type def calc_Risk(traffic_violations , risk_type1 , risk_type2 , risk_type3 , risk_type4): if traffic_violations == 4: risk_code = 1 risk_type1 = 'high' elif traffic_violations == 3: risk_code = 2 risk_type2 = 'moderate' elif traffic_violations == 2: risk_code = 3 risk_type2 = 'moderate' elif traffic_violations == 1: risk_code = 4 risk_type3 = 'low' elif traffic_violations == 0: risk_code = 5 risk_type4 = 'no' return risk_code , risk_type1 , risk_type2 , risk_type3 , risk_type4 #the insurance price def calcInsurance(age, number_tickets, risk_code): if age <= 24 and number_tickets >= 4 and risk_code == 1: insurance_price = 480 elif age >= 25 and number_tickets >= 4 and risk_code == 1: insurance_price = 410 elif age <= 24 and number_tickets == 3 and risk_code == 2: insurance_price4 = 450 elif age >= 25 and number_tickets == 3 and risk_code == 2: insurance_price = 390 elif age <= 24 and number_tickets == 2 and risk_code == 2: insurance_price = 405 elif age >= 25 and number_tickets == 2 and risk_code == 2: insuransce_price = 365 elif age <= 24 and number_tickets == 1 and risk_code == 3: insurance_price = 380 elif age >= 25 and number_tickets == 1 and risk_code == 3: insurance_price = 315 elif age <= 24 and number_tickets == 0 and risk_code == 4: insurance_price = 325 elif age >= 25 and number_tickets == 0 and risk_code == 4: insurance_price = 275 return insurance_price # function display customer name riskType, insurancePrice # and displays the amonunts def display_qoute(name, risk_type, insurance_price): print() print("Name of the customer: ", name) print("Risk type: ", risk_type) print("Insurance price: ${:.2f}".format(insurance_price)) #calling the main function main()
please help me finish this out. I am so stuck!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started