I took a JAVA class two years ago and haven't used it since. Now my brother is taking a JAVA class and he is asking me questions on how to troubleshoot his assignments. I can help him with VB/ORACLE/SQL but I am still new to JAVA. I was hoping someone here could help me figure out his problem so I can help him. I swear I am not cheating and I am not taking this class. Thank you.

Here is what he sent me:

Last time I e-mailed you I probably didn't give you enough enough for someone there to solve the problem...so I'm sending the whole thing!

First off I have this .java file that came with our assignment...it should enter in the values for me automatically and doesn't need to be changed, but here is the code anyway.

public class VendingMachineDriver {
public static void main(String args[]) {
VendingMachine v = new VendingMachine();
v.setPrice(27);
v.insertMoney(75);
v.printReceipt();
v.setPrice(173);
v.insertMoney(75);
v.insertMoney(50);
v.insertMoney(200);
System.out.println("Price = " + v.getPrice());
System.out.println("Money paid = " + v.getMoneyPaid());
System.out.println();

v.setPrice(451);
v.insertMoney(200);
v.insertMoney(600);
v.cancelPurchase();
v.setPrice(267);
v.insertMoney(120);
v.insertMoney(650);
v.printReceipt();

System.out.println("Total collected = " + v.getTotalCollected());
System.out.println();
}
}


Next is the file I've made from scratch....had those comments in there telling where to put stuff when I started it...


/**
* Write a description of class VendingMachine here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class VendingMachine {
// instance variables - replace the example below with your own
private int price;
private int paid;
private int total;


/**
* Constructor for objects of class VendingMachine
*/
public VendingMachine() {

// initialise instance variables
price = 0;
paid = 0;
total = 0;
}
public VendingMachine(int priceOfItem, int amountPaid) {

price = priceOfItem;
paid = amountPaid;
total = 0;

}

/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void setPrice(int amount) {

price = amount;
}

public void insertMoney(int amount) {

paid = paid + amount;

}
public int getPrice() {

return price;

}

public int getMoneyPaid() {

return paid;

}

public int getTotalCollected() {

return total;

}

public void reset() {

price = 0;
paid = 0;
total = 0;

}

public void cancelPurchase() {

int cancelPurchase;

}

pubic void printReceipt() {

paid();
price();
total = paid - price;
quarters = total / 25;
total = total % 25;
dimes = total / 10;
total = total % 10;
nickels = total / 5;
total = total % 5
pennies = total;
}
}

Now I'm not positive, but I think that last one won't compile because its not sure where to show the info at, or possibly it doesn't recognize quarters, dimes, etc. Help is needed! Thanks, talk to you later.


------------------------
It looks as if he need to declare and initialize the DIMES, QUARTERS, ETC. But would he do that in printReceipt or in the Main?