Question: Please help me write this Java class function. We are using the latest version of java. Thank You! Please provide screenshots of your code and
Please help me write this Java class function. We are using the latest version of java. Thank You! Please provide screenshots of your code and output since it is easier to see the format that way.

public class VendingMachineDemo { public static void main(String[] args) { VendingMachine machine1 = new VendingMachine(100); VendingMachine machine2 = new VendingMachine(200, "Library"); System.out.println("===== Welcome to the CSUMB Vending Machine ====="); System.out.println(machine1); System.out.println(""); System.out.println(machine2); System.out.println(" === Compare Two Machines ==="); System.out.println(machine1.equals(machine2)); machine1.setLocation("BIT104"); machine1.setName(50); machine1.setName(100); System.out.println(" === Machine Reset ==="); machine1.reset(4, 5, 0, 6); // In this method, we assume that a machine // administrator resets the contents of // a machine. machine1.addItems(1,2,3,4); // A system admin can add items to the machine System.out.println(machine1); System.out.println(""); machine1.displayMenu(); System.out.println(" === Buy an Item ==="); machine1.buyItem(); System.out.println(" === Buy another Item ==="); if(machine1.buyItem(1, 4) == false) { System.exit(1); } System.out.println(" === Return Two Items ==="); machine1.returned(1, 2); machine1.returned(2, 3); System.out.println(" === Buy another Item ==="); machine1.buyItem(3, 5); System.out.println(" === Pay for items selected. ==="); if(machine1.payment()) { System.out.println(" === Valid payment. ==="); machine1.displayReceipt(); } else { System.out.println(" === Invalid payment. Try one more time. ==="); if(machine1.payment()) { System.out.println(" === Print Receipt ==="); machine1.displayReceipt(); } else { System.exit(1); } } machine1.addItems(5,5,5,5); System.out.println(" === Machine Status ==="); machine1.status(); System.out.println(" ===== Thank you! ====="); } } 

![public class VendingMachineDemo { public static void main(String[] args) { VendingMachine machine1](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66efc158598d9_63166efc157c89c5.jpg)
For Part 1 of this homework, you will develop a class called VendingMachine that simulates an imaginary vending machine at CSUMB. In the program, a user can buy a bottle of water (1.50), a coffee ($2.00), a bag of chips (1.00), and a chocolate bar ($2.50) from the machine. The user can buy several items if they are available in the machine. For the payment, a user can use only cash (including coins). Additionally, an administrator of the machine can reset or refill the machine. Demo Program The following code presents a demo program that uses the VendingMachine class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
