Replies To: printing a bill

Re: printing a bill

Posted 29 October 2009 - 10:21 AM

first, explain what do you expect your program to do?
however, in first glance i noticed some problems in your code.
lets take milk in my example, but there are more variables that you repeat this mistake with.
you declare milk as a global variable and assigning it a value.
(better in such case to declare milk as a constant as: private final static double milk = 1.89;)
then you assign it the same value in your constructor.
also your constructor gets some parameters, however you do nothing with these parameter.
because you assign milk with "1.89" and not the value you get from the parameter double milk.

so my suggestion, is that you declare all variables which have a constant value as constants.
also your constructor shouldn't get parameters if you dont use your values.
and most importan. why do you return a value from your constructor?

Re: printing a bill

Posted 29 October 2009 - 10:31 AM

i want my program to create a receipt of the items shown with milk priced at 1.89 with quantity 5 and no tax
sugar priced at .60 with quantity 10 at 8%tax, candy priced at .89 with quantity 20 at 8%tax, gloves at 5.99 with quantity 4 at 4%tax, and apples for 1.29 quantity 6.5 with no tax.

i tried to have a constructor with no parameters and no return but everytime i compile i keep getting an error that i need a return statement?