• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any ideas about errors

 
ezekiel diligene
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12101
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks so much for all your assistance .. I'll be back to let you knoew the results Cheers Guys...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic