import java.io.*; class UseDrinksMachine3 { // Same as UseDrinksMachine2, but the machines are of type DrinksMachineA public static void main(String[] args) throws NumberFormatException, IOException { DrinksMachine cheap = new DrinksMachineA(25); DrinksMachine expensive = new DrinksMachineA(80); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int amount; System.out.print("\nHow much do you want to put in the cheap machine? "); amount = Integer.parseInt(in.readLine()); cheap.addMoney(amount); System.out.print("When you press the Coke button you get "); System.out.println(cheap.pressCoke()); System.out.print("How much more do you want to put in? "); amount = Integer.parseInt(in.readLine()); cheap.addMoney(amount); System.out.println("The amount showing is: "+cheap.showMoney()+"p"); System.out.print("When you press the Fanta button you get "); System.out.println(cheap.pressFanta()); System.out.print("\nHow much do you want to put in the expensive machine? "); amount = Integer.parseInt(in.readLine()); expensive.addMoney(amount); System.out.print("How much more do you want to put in? "); amount = Integer.parseInt(in.readLine()); expensive.addMoney(amount); System.out.println("The amount showing is: "+expensive.showMoney()+"p"); System.out.print("When you press the Coke button you get "); System.out.println(expensive.pressCoke()); System.out.println(); } }