Respuesta :
Here is the pseudocode algorithm that fulfills the requirements: DECLARE motorist_list AS ARRAY
DECLARE motorist AS RECORD
name: STRING
TRN_DL: STRING
tickets AS ARRAY OF RECORD
offence: STRING
cost: FLOAT
due_date: DATE
amount_received: FLOAT
points: INTEGER
FUNCTION add_motorist(motorist: RECORD)
motorist_list.append(motorist)
FUNCTION add_ticket(motorist_name: STRING, offence: STRING, cost: FLOAT, due_date: DATE)
FOR motorist IN motorist_list
IF motorist.name == motorist_name THEN
motorist.tickets.append(RECORD(offence, cost, due_date, 0.0))
total_points := calculate_points(offence)
motorist.points += total_points
IF motorist.points > 19 THEN
motorist.points := 0 // Reset points after suspension
PRINT "License Suspended for 2 years for " + motorist_name
ELSEIF motorist.points > 14 AND motorist.points <= 19 THEN
PRINT "License Suspended for 1 year for " + motorist_name
ELSEIF motorist.points > 9 AND motorist.points <= 13 THEN
PRINT "License Suspended for 6 months for " + motorist_name
END IF
BREAK
END IF
END FOR
FUNCTION calculate_points(offence: STRING)
points := 0 // Initialize points for this offense
// Assign points based on offence type (replace with your specific logic)
IF offence == "Speeding" THEN
points := 2
ELSEIF offence == "Reckless Driving" THEN
points := 5
END IF
RETURN points
FUNCTION display_unpaid_tickets()
total_unpaid := 0.0
FOR motorist IN motorist_list
FOR ticket IN motorist.tickets
IF ticket.amount_received == 0.0 THEN
PRINT "Motorist: " + motorist.name
PRINT("Offence: " + ticket.offence + ", Due Date: " + ticket.due_date + ", Cost: $" + STR(ticket.cost))
total_unpaid += ticket.cost
END IF
END FOR
END FOR
PRINT("Total Unpaid Balance: $" + STR(total_unpaid))
// Main program
motorist1 := RECORD("John Doe", "TRN12345", ARRAY(), 0)
motorist2 := RECORD("Jane Smith", "DL67890", ARRAY(), 0)
add_motorist(motorist1)
add_motorist(motorist2)
add_ticket("John Doe", "Speeding", 50.0, "2024-03-15")
add_ticket("Jane Smith", "Reckless Driving", 100.0, "2024-02-20")
add_ticket("John Doe", "Reckless Driving", 100.0, "2024-02-25") // John Doe will be suspended
display_unpaid_tickets()
This pseudocode defines a motorist record to store motorist information and a ticket record to store ticket details. It includes functions to add motorists, add tickets, calculate points based on the offence type, display suspended motorists and their penalties, and display the overall unpaid tickets and balances.Note that the specific logic for assigning points based on the offence type needs to be replaced with your specific requirements.
Here is the pseudocode algorithm that fulfills the requirements: DECLARE motorist_list AS ARRAY
DECLARE motorist AS RECORD
name: STRING
TRN_DL: STRING
tickets AS ARRAY OF RECORD
offence: STRING
cost: FLOAT
due_date: DATE
amount_received: FLOAT
points: INTEGER
FUNCTION add_motorist(motorist: RECORD)
motorist_list.append(motorist)
FUNCTION add_ticket(motorist_name: STRING, offence: STRING, cost: FLOAT, due_date: DATE)
FOR motorist IN motorist_list
IF motorist.name == motorist_name THEN
motorist.tickets.append(RECORD(offence, cost, due_date, 0.0))
total_points := calculate_points(offence)
motorist.points += total_points
IF motorist.points > 19 THEN
motorist.points := 0 // Reset points after suspension
PRINT "License Suspended for 2 years for " + motorist_name
ELSEIF motorist.points > 14 AND motorist.points <= 19 THEN
PRINT "License Suspended for 1 year for " + motorist_name
ELSEIF motorist.points > 9 AND motorist.points <= 13 THEN
PRINT "License Suspended for 6 months for " + motorist_name
END IF
BREAK
END IF
END FOR
FUNCTION calculate_points(offence: STRING)
points := 0 // Initialize points for this offense
// Assign points based on offence type (replace with your specific logic)
IF offence == "Speeding" THEN
points := 2
ELSEIF offence == "Reckless Driving" THEN
points := 5
END IF
RETURN points
FUNCTION display_unpaid_tickets()
total_unpaid := 0.0
FOR motorist IN motorist_list
FOR ticket IN motorist.tickets
IF ticket.amount_received == 0.0 THEN
PRINT "Motorist: " + motorist.name
PRINT("Offence: " + ticket.offence + ", Due Date: " + ticket.due_date + ", Cost: $" + STR(ticket.cost))
total_unpaid += ticket.cost
END IF
END FOR
END FOR
PRINT("Total Unpaid Balance: $" + STR(total_unpaid))
// Main program
motorist1 := RECORD("John Doe", "TRN12345", ARRAY(), 0)
motorist2 := RECORD("Jane Smith", "DL67890", ARRAY(), 0)
add_motorist(motorist1)
add_motorist(motorist2)
add_ticket("John Doe", "Speeding", 50.0, "2024-03-15")
add_ticket("Jane Smith", "Reckless Driving", 100.0, "2024-02-20")
add_ticket("John Doe", "Reckless Driving", 100.0, "2024-02-25") // John Doe will be suspended
display_unpaid_tickets()
This pseudocode defines a motorist record to store motorist information and a ticket record to store ticket details. It includes functions to add motorists, add tickets, calculate points based on the offence type, display suspended motorists and their penalties, and display the overall unpaid tickets and balances.Note that the specific logic for assigning points based on the offence type needs to be replaced with your specific requirements.