Lab: Car Insurance Example

Fifteen minutes can save you 15% or more

Slides 4-9 in the deck for today (Complex conditions) walks through analyzing a car insurace premium estimation problem. Your job here is to write an interactive program that solves that problem, using two different approaches.

Your program should:

  1. Ask the user their name, gender, age and how many outstanding tickets they have
  2. Tell them their estimated premium based on these rules:
    Gender Age Annual Premium
    Male Under 21 1500 + 200 for every outstanding ticket
    Male 21 to 29 1200 + 100 for every outstanding ticket
    Male 30 and older 1000 + 100 for every outstanding ticket
    Female Under 21 1200 + 200 for every outstanding ticket
    Female 21 and older 1000 + 100 for every outstanding ticket

Version 1: if-else tree

Write the program using an if-else tree with five branches and complex conditions.

Version 2: nested if-else trees

Write the program using nested if-else trees as suggested in the slides as "Alternate Design".

Attach both working programs to the lab to submit.