Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error: Cannot Find Symbol

 
Rykurex Peters
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This program is intended to calculate the amount of paint needed, and cost, to paint a room (4 walls + ceiling)

Edit: My original problem has been solved, now I just have a question about these two codes, which (I hope) do the same thing.
Also, I know I have a method call to ceiling, which currently doesn't exist, the point of this method is to give me an integer value to store as number of tins (because you can't buy half a tin of paint...) is there a simple way for me to do this ?
Thanks again everybody <3

This first code has a separate method for each calculation / assignment to a variable. I want to know if this is actually needed? Or, because these calculations are simple, is it both easier and more functional to do all of these calculations under one method?




Second code;


 
fred rosenberger
lowercase baba
Bartender
Posts: 12180
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have a method named areaToPaint(), but you don't have a variable named that. so the line

is wrong - you are trying to save a value in a variable that doesn't exist.
 
Rameshwar Soni
Ranch Hand
Posts: 247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your code you are using variables but you haven't declared them before using, so along with your length, width, height variables declare them too. i.e.


Once you do that you will have one error pointing to the ceiling method i.e.


Here ceiling is method since it has () i.e. parenthesis after its name. So check it out.

And Welcome to Ranch!!!
 
Rykurex Peters
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot guys, I'll click resolved in a few hours, I just want to see if anybody replies about the question
I'm really impressed with how fast people got back too, it's been a big help
 
Rameshwar Soni
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Rykurex Peters----------- One advice that i would like to give is that after you receive any answers you should not edit or do changes in your Original question because then the answers given seems to be meaningless, instead you should post a new reply to the same thread with your updated code.

Say for example Fred and me both told you that you haven't declared variables in your original code and then after receiving the answers you went and did those changes in your original question and now Fred's and mine answer looks meaningless to others who view this thread.

 
Rameshwar Soni
Ranch Hand
Posts: 247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rykurex Peters wrote:
Edit: My original problem has been solved, now I just have a question about these two codes, which (I hope) do the same thing.

This first code has a separate method for each calculation / assignment to a variable. I want to know if this is actually needed? Or, because these calculations are simple, is it both easier and more functional to do all of these calculations under one method?



So basically now you want to know which code is better, more functional, has good performance etc. out of the 2 codes.

I think you should not worry about all these things (i.e. performance) at this stage.

So
  • do what you feel is simple, comfortable and gives you correct answer
  • Focus on learning and understanding concepts in Java


  • Once you are done with this then there are many books to help you write BETTER code like Effective Java but before this at least finish concepts in Java.

    Thanks......
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic