"cannot find symbol" error
Hi! I'm working through a book, Introduction to Java Programming by Y. Daniel Liang, and I'm on... lets see... page 41.
I copied this exercise exactly out of the book:
publicclass SalesTax{
publicstaticvoid main(String[] args){
double purchaseAmount = 197.55;
double tax = purchaseAmount * 0.06;
System.out.prntln((int)(tax * 100) / 100.0);
}
}
This particular exercise is used as an example of casting. Anyway, when I try to compile it (from the command line), I get the following error:
C:\Program Files\Java\JavaBook>javac SalesTax.java
SalesTax.java:5: cannot find symbol
symbol : method prntln(double)
location: class java.io.PrintStream
System.out.prntln((int)(tax * 100) / 100.0);
^
1 error
I am driving myself nuts trying to figure this out. Should I just give up and move on to the next exercise in the book?
Please help; I am an absolute n00b.
Thanks!
[1362 byte] By [
Xtala] at [2007-11-27 9:56:32]

In this situation, you have to study what the error message is telling you and follow up on that info. The book may have a typo, and you may do well to look up what methods are contained in the System.out package.
> Hi! I'm working through a book, Introduction to Java
> Programming by Y. Daniel Liang, and I'm on... lets
> see... page 41.
>
> I copied this exercise exactly out of the book:
>
> public class SalesTax {
>public static void main(String[] args) {
>double purchaseAmount = 197.55;
> ouble tax = purchaseAmount * 0.06;
> System.out.prntln((int)(tax * 100) / 100.0);
> }
> }
>
> This particular exercise is used as an example of
> casting. Anyway, when I try to compile it (from the
> command line), I get the following error:
>
> C:\Program Files\Java\JavaBook>javac SalesTax.java
> SalesTax.java:5: cannot find symbol
> symbol : method prntln(double)
> location: class java.io.PrintStream
> System.out.prntln((int)(tax * 100) / 100.0);
>^
>
> I am driving myself nuts trying to figure this out.
> Should I just give up and move on to the next
> exercise in the book?
>
> Please help; I am an absolute n00b.
>
> Thanks!
Hello Xtal,
Your print to console line has a typo... it should read
System.out.println((int)(tax * 100) / 100.0);
That should fix your problem. Happy learning,
Nexeh
> Hello Xtal,> ......> That should fix your problem. Happy learning,> NexehNexeh:Your answer fixed his error. Mine teaches him how to fix future errors. Please think this over.
petes1234,Not everyone on the Internet is a him. Please think this over.xoxo,Crystal
Xtala at 2007-7-13 0:26:43 >

> petes1234,> > Not everyone on the Internet is a him. Please think> this over.> > xoxo,> > Crystaloops, my bad. Thanks for correcting me!
Even after copy-n-pasting the revised code I still couldn't figure it out.Then I looked.Really really looked.I was spelling the word "print" wrong!Oh the shame.Thanks petes1234 and Nexeh.
Xtala at 2007-7-13 0:26:43 >

> you may do well to> look up what methods are contained in the System.out> package.Er, how would I go about doing this?Thanks for your help.
Xtala at 2007-7-13 0:26:43 >

> Er, how would I go about doing this?
Me, I usually don't remember the http addresses to the Java API's, but fortunately I don't have to. I just google whatever I want. Here, I googled:
java "System.out"
the first hit was this:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
Then I looked at System.out and saw that it is in fact a PrintStream object. There's a link to PrintStream which when clicked brings me here:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintStream.html
And those are the methods available.
Message was edited by:
petes1234
> > Not everyone on the Internet is a him.
>
> oops, my bad. Thanks for correcting me!
But my main point remains:
If you give a man (or a woman) a fish they eat fish for a day.
But if you teach a man (or woman) to fish, then they sit on a boat and drink beer all day.
Think that one over.
Hey Petes1234,
I understand completely what your saying but there is also no reason to discourage anyone from posting, such as myself. Being a complete newbie to the Java field myself I can understand Xtal's frustration. You are however correct that it's important to learn how to search the API but i can guarantee you that she will NEVER forget this mistake and what she has learned from it...
Sorry, just disappointed that my first post on the forum had a comment back like that... I don't mean to be snappy.
> Sorry, just disappointed that my first post on the
> forum had a comment back like that... I don't mean to
> be snappy.
No problem. But anytime you join a new forum, it's probably a good idea to read as many posts as possible for several days before posting yourself. This way you learn the forum culture and etiquette.
BTW, I think my initial note to you was quite benign compared to what I've seen here.
Good to know! I see that you have a silver star which tells me that you are an active member, so i do appreciate any advice that you would give. I have a feeling that i will be around a lot more seeing as I just accepted a position as a java developer. Is there any advice that you could give me, etiquette wise or developer wise?
> Good to know! I see that you have a silver star which
> tells me that you are an active member, so i do
> appreciate any advice that you would give. I have a
> feeling that i will be around a lot more seeing as I
> just accepted a position as a java developer. Is
> there any advice that you could give me, etiquette
> wise or developer wise?
congrats on the new position. hm, advice? Most of us try to help newbie posters help themselves if possible, and we try to discourage folks from just getting "the answer". It's nice to have a thick skin here. Good luck, and hope to see you around.