In: Computer Science
A soft drink vending machine dispenses cans of drinks at the JKUAT cafeteria. The machine waits for students and/or staff to insert coins. All soft drinks cost KShs. 50 and the machine can only accept Ten, Twenty and Forty shilling coins. A customer must insert a total of fifty shillings for the machine to dispense drinks.
(i.) Give the formal definition of the above machine, as a Finite Automaton.
(ii.) Is the machine deterministic or non-deterministic? Justify your answer
(iii.) Draw a state transition diagram for the above machine
(iv.) Write a C++ program to implement the above machine
1. The vending machine is the type of finite automation. Beacuse it includes number of inputs and number of outputs. It has three inputs ten, twenty, fourty as coins. If customer insert ten or twenty or fourty coins then machine gives perticular soft drink. Also if customer want to take drink of 50 coins then machine just add ten and fourty and give 50 coins drink. So due to this the number of inputs relates to each other and gives a desirable outputs is called fininte automation.
2.The machine is deterministic. Because all outputs given by machine is pre defined. Drink quantity also pre defined and based on coins ten, twenty and fourty.
3. State transition diagram :-
[50 coins] -- [ [S1][S2][S3] ] -- [S1+S3] -- [Drink 50 coin]
- [50 coins] : Input from customer.
- [[S1][S2][S3]] :Variables [[10],[20],[40]]
- [S1+S3] : Adding of Variables 10 and 40
- [ Drink 50 Coins ] : Output is 50 coins drink.