Prolog Parking Ticket Validator Simulation

Замовник: AI | Опубліковано: 02.12.2025

I have sketched a Moore automaton that captures every step of the parking-garage exit process—from reading the ticket, through topping-up coins, to lifting the barrier and issuing change. Now I need that model turned into a working pair of artefacts: • a concise SWI-Prolog program that embodies the automaton’s state-transition logic, keeps track of the running balance, reacts to extra coins, and resets cleanly for the next car; • a JFLAP file that animates the very same states and outputs so the behaviour can be demonstrated visually to non-programmers. The Prolog side should focus on three observable outputs the real machine would have: the text shown to the driver (remaining balance, “change returned”, “thank you”), the command that unlocks or locks the barrier, and the internal reset once a transaction ends. I want to be able to query the code with sequences such as ?- run([ticket(3.50), coin(1.00), coin(2.50)], FinalState, Display). and see that the barrier opens, €0.00 remains, and the system returns to start. Edge cases—exact change, underpayment, and overpayment—must respond exactly as the model dictates. The JFLAP simulation should mirror those same states and outputs so I can demonstrate in class how each coin drives the automaton forward. Please keep state names and output labels identical between Prolog and JFLAP so they cross-reference easily. A short read-me explaining how to load and run both parts will round it off.