Could someone help me find my errors on this program?? (homework)
Sub program
Code Java:
public class CashRegister {
public CashRegister() {
purchase = 0;
payment = 0;
}
public void recordPurchase(double amount){
double purchase = purchase + amount;
}
public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
double payment = dollars + quarters*QUARTER_VALUE + dimes*DIME_VALUE
+ nickels*NICKEL_VALUE + pennies*PENNY_VALUE;
}
public double giveChange() {
double change = payment - purchase;
purchase = 0;
payment = 0;
return change;
}
private double purchase;
private double payment;
public static final double QUARTER_VALUE = 0.25;
public static final double DIME_VALUE = 0.1;
public static final double NICKEL_VALUE = 0.05;
public static final double PENNY_VALUE = 0.01;
}
Errors for sub program:
Code Java:
--------------------Configuration: CashRegister - jre6 <Default> - <Default>--------------------
C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegister.java:9: ')' expected
public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
^
C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegister.java:9: ';' expected
public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
^
2 errors
Process completed.
Main program
Code Java:
public class CashRegisterTester{
public static void main(String[] args) {
CashRegister register = new CashRegister();
register.recordPurchase(0.75);
register.recordPurchase(1.50);
register.enterPayment(2,0,5,0,0);
System.out.print("Change = ");
System.out.println(register.giveChange());
}
}
Errors for main program:
Code Java:
--------------------Configuration: CashRegisterTester - jre6 <Default> - <Default>--------------------
C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegisterTester.java:3: cannot find symbol
symbol : class CashRegister
location: class CashRegisterTester
CashRegister register = new CashRegister();
^
C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegisterTester.java:3: cannot find symbol
symbol : class CashRegister
location: class CashRegisterTester
CashRegister register = new CashRegister();
^
2 errors
Process completed.
Please help!
I get the feeling that the main just can't seem to find the sub.
Re: Could someone help me find my errors on this program?? (homework)
See the method declaration on line 9 of CashRegister - parameters are separated by comma's and not semi-colons.
Re: Could someone help me find my errors on this program?? (homework)
Quote:
Originally Posted by
copeg
See the method declaration on line 9 of CashRegister - parameters are separated by comma's and not semi-colons.
Thank you so much!!!