What is the problem?

+1 vote
asked Oct 6 by anonymous
#Constants

number_of_traffic_violations = 0
riskCode = 0
riskType = 0
age = 0
number_of_tickets = 0
insurancePrice = 0

def getinput():
    global number_of_traffic_violations

#Number of trafic violations
    name = int(input("Enter the name of the customer:"))
    age = int(("Enter the age of the customer:"))
    while age < 16:
        print("Invalid Entry")
        age = int(("Enter the age of the customer:"))
        number_of_traffic_violations = int(input("Enter the number of traffic violations: ")

#Risk code
def calRisk(type):
    global riskType
    global riskCode
    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 = 2
        riskType = "Moderate"
    elif number_of_traffic_violations == 1:
        riskCode = 3
        riskType = "Low"
    elif number_of_traffic_violations == 0:
        riskCode 4
        riskType = "No"
    else:
        riskCode = 0
            riskType = 0

#Insurance pricing
def calInsurance(price):
    global age
    global number_of_tickets
    global riskCode
    if age <= 25 and number_of_tickets >= 4 and riskCode == 1:
        insurancePrice = 480
    elif age >= 25 and number_of_tickets >= 4 and riskCode == 1:
        insurancePrice = 410
    elif age <= 25 and number_of_tickets == 3 and riskCode == 2:
        insurancePrice = 450
    elif age >= 25 and number_of_tickets == 3 and riskCode == 2:
        insurancePrice = 390
    elif age <= 25 and number_of_tickets == 2 and riskCode == 2:
        insurancePrice = 405
    elif age >= 25 and number_of_tickets == 2 and riskCode == 2:
        insurancePrice = 365
    elif age <= 25 and number_of_tickets == 1 and riskCode == 3:
        insurancePrice = 380
    elif age >= 25 and number_of_tickets == 1 and riskCode == 3:
        insurancePrice = 315
    elif age <= 25 and number_of_tickets == 0 and riskCode == 4:
        insurancePrice = 325
    elif age >= 25 and number_of_tickets == 0 and riskCode == 4:
        insurancePrice = 275
    else:
        insurancePrice = 0

#Show risk type
riskType = number_of_traffic_violations + riskCode
    print("Risk Type:,")

#Show insurance price
insurancePrice = age + number_of_tickets + rickCode
    print("Insurance Price:$", format(insurancePrice, '.2f)

#Display final
def showPurchase(riskType, insurancePrice):
    print("Risk Type:,")
    print("Insurance Price:$", format(insurancePrice, '.2f)

getinput()
calRisk(type)
showPurchase(riskType, insurancePrice)

2 Answers

0 votes
answered Oct 7 by David
To answer your initial question: you're missing a ')' at end of your getinput function.

But to be realistic, there's a lot of syntax errors that even I had to spend some time sifting through to just get the program up and running.  I've listed by ## error number) ### throughout the code explaining what the error was and how it was fixed.  What I recommend you do for next time is to work on programming one function first, verify that portion of the code is up and running, and then continue writing your code.  It really helps out in the beginning to code in this linear fashion as the longer the code, the more complicated things can get real quick.

I also notated a few logical errors and missing print statements that you'll need to fix.

Cheers,
    David

//============================================================

#Constants
## 00) Global Constants should always be in all CAPS #######
number_of_traffic_violations = 0
riskCode = 0
riskType = 0
age = 0
number_of_tickets = 0
insurancePrice = 0

## 13) Illogical code -- no input of number_of_traffic_violations if age is > 16 on first run ####
def getinput():
    global number_of_traffic_violations

#Number of trafic violations
    ## 6) name shouldn't be converted into an int #######
    name = input("Enter the name of the customer:")
    ## 7) missing 'input' #######
    age = int(input("Enter the age of the customer:"))
    while age < 16:
        print("Invalid Entry")
        ## 8) missing 'input' #######
        age = int(input("Enter the age of the customer:"))
        ## 1) Missed ending ')' #######
        number_of_traffic_violations = int(input("Enter the number of traffic violations: "))

#Risk code
def calRisk(type):
    global riskType
    global riskCode
    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 = 2
        riskType = "Moderate"
    elif number_of_traffic_violations == 1:
        riskCode = 3
        riskType = "Low"
    elif number_of_traffic_violations == 0:
        # Missed '=' sign
        riskCode = 4
        riskType = "No"
    else:
        riskCode = 0
        ## 2) Mis-alingned riskType #######
        riskType = 0

#Insurance pricing
def calInsurance(price):
    global age
    global number_of_tickets
    global riskCode
    if age <= 25 and number_of_tickets >= 4 and riskCode == 1:
        insurancePrice = 480
    elif age >= 25 and number_of_tickets >= 4 and riskCode == 1:
        insurancePrice = 410
    elif age <= 25 and number_of_tickets == 3 and riskCode == 2:
        insurancePrice = 450
    elif age >= 25 and number_of_tickets == 3 and riskCode == 2:
        insurancePrice = 390
    elif age <= 25 and number_of_tickets == 2 and riskCode == 2:
        insurancePrice = 405
    elif age >= 25 and number_of_tickets == 2 and riskCode == 2:
        insurancePrice = 365
    elif age <= 25 and number_of_tickets == 1 and riskCode == 3:
        insurancePrice = 380
    elif age >= 25 and number_of_tickets == 1 and riskCode == 3:
        insurancePrice = 315
    elif age <= 25 and number_of_tickets == 0 and riskCode == 4:
        insurancePrice = 325
    elif age >= 25 and number_of_tickets == 0 and riskCode == 4:
        insurancePrice = 275
    else:
        insurancePrice = 0

#Display final
def showPurchase(riskType, insurancePrice):
    ## 11) Missing variable 'riskType' #######
    print("Risk Type:,")
    ## 4) Missing <singleQuote> and ')'
    print("Insurance Price:$", format(insurancePrice, '.2f'))

    ## 3) Are these supposed to in showPurchase()? #######
    #Show risk type
    riskType = number_of_traffic_violations + riskCode
    ## 12) Missing variable 'riskType' #######
    print("Risk Type:,")

    #Show insurance price
    ## 10) Typo Error => rickCode != riskCode   #######
    insurancePrice = age + number_of_tickets + riskCode
    ## 5) Missing <singleQuote> and ')'
    print("Insurance Price:$", format(insurancePrice, '.2f'))

getinput()
calRisk(type)
showPurchase(riskType, insurancePrice)
0 votes
answered 6 days ago by (190 points)
reshown 5 days ago by
If any user enter vehicle name and age of customer, it has check whether entered age is more than 16. If it's less than it has redirect the main windows and to re-enter the name and age. If the condition has satiesfied, then get down the risktype and risk code based on violation. And also display the price based on risktype & violation.

Finally has to display the risktype , insurance price and  final price allow with two floating values.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...