• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can someone tell me what I am doing wrong?

 
Alec Sultana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I have my A level computing project coming up, and I am struggling. So hopefully I'll find some much needed help here

Anyway, I was writing this program, more so modifying. 2 classes. I seem to have a problem with the 3rd and 5th line of the tuna class. It worked fine when I wanted to pass on a String to what was Simplemessage. But then I decided to try something out, and use integers, furthermore calculating something simple.

Also can anyone tell me what these error codes mean, so that in the future I won't need to trouble you guys for the same problem

error: <identifier> expected
error: cannot find symbol

Any help appreciated,

Alec



 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

This line:

should have looked like this:

You have to specify the type (int in this case) for each argument separately. int fnum, snum doesn't work.
 
Alec Sultana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Welcome to the Ranch.

This line:

should have looked like this:

You have to specify the type (int in this case) for each argument separately. int fnum, snum doesn't work.


Thank you, thats all I needed

Man I'm bad at this
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You ought to go through the code conventions (those are very old, and many people use a different indentation convention.)

You have some strangely-named classes: what have tuna and addition to do with each other? Avoid two declarations in the same line; fnum and snum each deserve a line to themselves.
 
Alec Sultana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You ought to go through the code conventions (those are very old, and many people use a different indentation convention.)

You have some strangely-named classes: what have tuna and addition to do with each other? Avoid two declarations in the same line; fnum and snum each deserve a line to themselves.


True, But I have been watching a lot of TheNewBoston's videos on youtube, and he always uses those two class names in his video examples, so for the sake of making me remember the appropriate syntax of things, I decided to use the same name. ( For my revision and playing with code only though )
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to get used to doing things right from day 1. If you get into bad habits now (or, more precisely, since you have got into bad habits already), they are so much more difficult to break when you are writing what matters. And style problems will lose you marks.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO, variable names like "fnum" and "snum" should be avoided. Fred's number? Favorite number? Fine Number?

You have a keyboard, you have plenty of memory and disk space..."firstNumber" makes it obvious what you are talking about.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic