Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Highway Robbery! Use skills learned in Units 1 - 5 and include: user defined input function(s), user defined calculation function(s) and user defined output function(s)

Highway Robbery!

Use skills learned in Units 1 - 5 and include:

  • user defined input function(s), user defined calculation function(s) and user defined output function(s)
  • project must contain a minimum of 3 def statements
  • passing variables between functions
  • elif statements
  • (see grading rubric for full details)

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 -----.

#Create a program that will prepare automobile liability insurance estimates #for customers.

def main():

name = input("Enter the name of the customer:") age = int(input("Enter the age of the customer:")) if age <16 or age>105: print("Invalid Entry") age = int(input("Enter the age of the customer:")) number_of_traffic_violations = int(input("Enter the number of traffic" + \ " violations:"))

def calRisk(name,age,number_of_traffic_violations): if number_of_traffic_violations >= 4: riskCode = 1 riskType = 'high' elif number_of_traffic_violations == 3: riskCode = 2 riskType = 'moderate' elif number_of_traffic_violations == 2: riskCode = 3 riskType = 'moderate' elif number_of_traffic_violations == 1: riskCode = 4 riskType = 'low' elif number_of_traffic_violations == 0: riskCode = 5 riskType = 'no' return riskCode , riskType

def calinsurancePrice(name,age,number_of_traffic_tickets,riskCode,riskType): if age < 25 and number_of_traffic_tickets >= 4 and riskCode == 1: insurancePrice = 480 elif age >= 25 and number_of_traffic_tickets >= 4 and riskCode == 1: insurancePrice = 410 elif age <= 24 and number_of_traffic_tickets == 3 and riskCode == 2: insurancePrice = 450 elif age >= 25 and number_of_traffic_tickets == 3 and riskCode == 2: insuranceprice = 390 elif age <= 24 and number_of_traffic_tickets == 2 and riskCode == 2: insurancePrice = 405 elif age >= 25 and number_of_traffic_tickets == 2 and riskCode == 2: insuransceprice = 365 elif age <= 24 and number_of_traffic_tickets == 1 and riskCode == 3: insurancePrice = 380 elif age >= 25 and number_of_traffic_tickets == 1 and riskCode == 3: insurancePrice = 315 elif age <= 24 and number_of_traffic_tickets == 0 and riskCode == 4: insurancePrice = 325 elif age >= 25 and number_of_traffic_tickets == 0 and riskCode == 4: insurancePrice = 275 return calinsurancePrice

#call main function main() #display output def display_qoute(name, riskType, insurancePrice): print() print(name,",as a",riskType,"risk driver, your insurance will be $[.2f]".format(insurance_price))

I can't get my program to completely run. It ask for age name and number of tickets but I can't get it to complete the rest. It doesn't display the cost or risk? Please help!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions