Re: Beginners needing help
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Can you explain what problems you are having with your assignment?
Ask some specific questions about the program's code and what you need to do.
Re: Beginners needing help
I'm trying to get the output to say The charge for this table is $400.0. The problem im having is i added all the variables they asked and the if statements but it does not compile and i feel as if im leaving something out. When i try to compile the error im getting is:
Furniture.java:23: error: cannot find symbol
String wood = oak;
^
symbol: variable oak
location: class Furniture
Re: Beginners needing help
String wood = oak;
The compiler thinks oak is the name of a variable. If you mean for it to be a String, enclose it it "s
When comparing the contents of objects like Strings, use the equals() method not the == operator.
The = operator is the assignment operator, not the equality testing operator: ==.
Re: Beginners needing help
Can you give me an example of what you mean when you say use the () method not == operator. I ran the code and it said the charge for this table is $300.00 and it should be $400.00. I think i left something out with the leaves but i dont know exactly what to add.
Re: Beginners needing help
Did you try doing a search for equals? Its used lots of times.
Re: Beginners needing help
Oh i understand what your saying now. I was reading it as use the equals "()" method not the == operator instead of use the "equals()" method not the == operator. So i would say if (wood.equals("mahogany")). Thank i got it i also realized that i needed to add the two leaves which were $50 each that gave me the $100 i need. Thanks for the help Norm
Code java:
table = 0.00;
if (area > 750)
{charge += 50;}
if (wood.equals("mahogany"))
{charge += 200.00;}
if (wood.equals("oak"))
{charge += 100.00;}
Re: Beginners needing help
Re: Beginners needing help
This is really not important at all, but you write:
table = 0.00 twice,
once when you initialize the variable and once again when you are about to do your if statements.