I need to write a program that accepts coins(nickles, dimes, quarter) and single dollar bills, dispenses the item and returns change if the deposited money exceeds the item's value.
There are 5 items with the prices of: 65 cents, 95 cents, 50 cents, 110 cents and 75 cents. There is more that needs to be done with LED lights and the machine breaking but I'm stuck with how to initialize these and have the user input the coins and it dispense. HELP!
This is all I have so far:

class VendingMachine {


	public class VendingMachine{
		private int itemPrice;
		private int balance;
		private int totalCollected;


		public VendingMachine(int itemCost){
			itemPrice = itemCost;
			balance = 0;
			totalCollected = 0;
		}

It's sort of difficult to help without knowing what you intend the overall design to be. It's hard to suggest an overall design without knowing the requirements. At minimum, post what the program should prompt the user, the user's input, and the desired output for that input. In addition, we have no idea what your experience level in Java is and whether you understand the concepts involved in Object Oriented programming. At first glance, I would imagine that a vending machine would contain a Collection of type Beverage, where Beverage would have attributes like "name", "quantitySold", "quantityInStock", and "price".

You can make this quite elaborate or fairly simple. So my first comment would be to probably remove the itemPrice attribute from VendingMachine and stick it in Beverage. totalCollected makes sense as an attribute, but I'm not sure what balance represents.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.