SOLVED!
Thanks
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
SOLVED!
Thanks
Last edited by UbaldoJimenez; April 4th, 2012 at 07:50 PM.
What does "did not work" mean? Specifically I guess we are talking out the lines:I've tried Car1(sellingprice) and made a variable for it in Car but it did not work.
//14 System.out.println("\n" + car1.CalcSellingprice() + car2.CalcSellingprice() + car3.CalcSellingprice() + car4.CalcSellingprice());
What output does that expression produce?
-----
A separate matter, but it would be a good idea to follow Java coding conventions and begin your methods with a lower case letter: calcTax() etc.
It produced: 18889.529925.042000.025200.0
Which are the totals of each separate car without spacing but I need the total of them all.
Thanks
Yes, what you get is the string concatenation of all the items. + does two things in Java: it performs string concatenation and it performs arithmetic addition. Basically you should do the additions first, before the concatenation. And to determine the order of operations we use parentheses.
public class Foo { public static void main(String[] args) { System.out.println("" + 4 + 2); System.out.println("" + (4 + 2)); } }
Got it I also corrected the capitalization on my calcs.
Thanks I greatly appreciate the help brockway.
You're welcome - I'm glad you've got it sorted out.