|
Help needed writing a program...
Hi everyOne,
I m trying 2 write a program for a Vending machine. The main purpose of the machine is to accept coins (1pound, 50 pence, and 20 pence) from a customer and dispense the item. I have two questions regarding this example;
Question 1: If I need to write a method to accept coins (mentioned above) from a customer, and then write a function of the total money inserted; How could I output total money inserted by a customer as pounds & pence, e.g. (£1.70). I have been using double to declare coin variable but when I output the result it shows as £1.7. Eliminating the last 0 in the end.
Question 2: My second question is about the same java program 'vending machine. If I need to write a 'cancel' method for a vending machine class, which should refund all coins inserted by a customer (taking in to consideration that customer has not spend any amount, all they wants their coins back). How can I implement this method?
Thanks,
Francis
|