import java.io.*; class UseDrinksMachine6 { // Uses machines of type DrinksMachineC, with Change button, and // need to load cans. public static void main(String[] args) throws NumberFormatException, IOException { DrinksMachineC cheap = new DrinksMachineC(25); DrinksMachineC expensive = new DrinksMachineC(80); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int amount; System.out.println("\nLoad the cheap machine with 10 Cokes"); cheap.loadCokes(10); System.out.print("How 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.println("Load the cheap machine with 8 Fantas"); cheap.loadFantas(8); System.out.print("When you press the Fanta button you get "); System.out.println(cheap.pressFanta()); System.out.print("When you press the Change button you get "); System.out.println(cheap.pressChange()); System.out.println("\nLoad the expensive machine with 1 Coke"); expensive.loadCokes(1); System.out.println("Load the cheap machine with 5 Fantas"); expensive.loadFantas(5); System.out.print("How much do you want to put in the expensive machine? "); amount = Integer.parseInt(in.readLine()); expensive.addMoney(amount); System.out.print("Check the price of the expensive machine: "); System.out.println(expensive.showPrice()); 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.print("When you press the Change button you get "); System.out.println(expensive.pressChange()); System.out.println("Change the price of the expensive machine to 70p"); expensive.changePrice(70); System.out.print("How much do you want to put in the expensive machine? "); amount = Integer.parseInt(in.readLine()); expensive.addMoney(amount); System.out.print("When you press the Coke button you get "); System.out.println(expensive.pressCoke()); System.out.print("When you press the Fanta button you get "); System.out.println(expensive.pressFanta()); System.out.print("When you press the Change button you get "); System.out.println(expensive.pressChange()); System.out.println(); } }