aspose file tools
The moose likes Beginning Java and the fly likes Any ideas about errors Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Any ideas about errors" Watch "Any ideas about errors" New topic
Author

Any ideas about errors

ezekiel diligene
Greenhorn

Joined: Dec 01, 2005
Posts: 5
class CarPark1
{
// private instance variables
private int Payment, total, balance;

// public no-argument constructor
public CarPark1() { }

// public constructor with three arguments
public CarPark1(int p, int t, int b)
{
payment = p;
total = t;
balance = b;
}

// public 'set' methods
public void setPayment(int p) { payment = p; }
public void setTotal(int total) { total = t; }
public void setbalance(int balance) { balance = b; }

// public method to calculate the total
public int calculateTotal()
{
int balance = total - payment;
// more code here to show balance =>0 message displayed
return balance;
}
}


Any advice would be much appreciated. I'm fairly new at this....


b.notes
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9956
    
    6

help us help you. what exact errors are you getting? what are you expecting to see?

also, if you'd use the code tags, it'd preserve your formatting, and make your code easier to read. use those "instant UBB" buttons to get the tags, then paste your formatted code between them.


Never ascribe to malice that which can be adequately explained by stupidity.
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 2542
    
  10

One problem is you declare an instance variable as Payment, then use it as payment. Java variables are case sensitive, and by convention should always start with a lowercase letter.
Srinivas Kumar
Ranch Hand

Joined: Jul 14, 2005
Posts: 52
Also u haven't declared the variable t in the method setTotal().
Same is the case with the variable b in setbalance() method.
ezekiel diligene
Greenhorn

Joined: Dec 01, 2005
Posts: 5
thanks so much for all your assistance .. I'll be back to let you knoew the results Cheers Guys...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Any ideas about errors
 
Similar Threads
cannot resolve symbol
Mortgage Calculator and GUI
Having trouble understanding an error code i keep getting. Please help!
Program like ATM where person enters amount in dollars and cents but program uses int for monies
Illegal start?