What'd be wrong withApart from line lengths.
salvin francis wrote:. . .
Campbell Ritchie wrote:...and the comments aren't helpful. I fact, I think some of them are incorrect.
Campbell Ritchie wrote:What'd be wrong withApart from line lengths.
Junilu Lacar wrote:There are lots of errors in the code you posted. The lack of proper formatting makes it difficult to spot them though.
1. Your calcTotals() method is declared inside the main() method. You can't do that.
2. You have a number of variables which you declare twice. That's not a good practice as it can lead to errors and/or confusion.
3. You have semi-arbitrary code blocks where a code block is not necessary. In fact, some of those arbitrary code blocks contribute to the confusion.
Here's your code properly formatted and indented (I suggest you pay more attention to this detail in the future if you want to avoid unnecessary headaches—you're shooting yourself in the foot, in the arm, in the stomach, etc. by not formatting your code properly):
So, where did I declare variables twice?
Please write code in the code tags and text outside, otherwise your questions are very hard to find.
Danielle Beard wrote:. . . So, where did I declare variables twice? . . .
This is what it would have looked like if you got the code tags right, but it still isn't correct, I am afraid:-I hope that isn't exactly what you are using; you are missing the spaces at the start of line 4. Remember who is going to have the most trouble if you write badly indented code, and who needs the help from the indentation most. You yourself.
Danielle Beard wrote:. . .
public class Program3hw
public static final double taxRate = .060;
. . .
'Fraid you have got a bit more to learn than that. A void method might do all sorts of things. All void means is that it doesn't leave a value behind. If you declare a method with any other type, not void, it means that method leaves a trace behind itself in the form of something of the type you have given it.
Danielle Beard wrote:. . . Static void means we arent doing anything, . . .