• Post Reply Bookmark Topic Watch Topic
  • New Topic

java multiple parameters for beginner  RSS feed

 
Vadim Melders
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Im new to java. I got question - getting error on this and cannot find any answers around, though Im sure the problem can be resolved in a sec by someone.

package EnterQuestionnaire;
import java.util.Scanner;



It gives me error in the last line with - age.



It works with name but doesnt work with age.

Any help would be appreciated.


 
Zachary Griggs
Ranch Hand
Posts: 83
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that you did not declare a variable called "age". Instead, when you asked the user for their age, you saved it into a variable called "eent", so that's the variable you would need to pass to the function. Based on the name of the variable, it looks like you wanted to call the "eent" function in class entage. If you wanted to do this, you would have to first save the age into a different int variable (probably call it age), then call entage.eent(age). you should also consider whether you want it to be static or not: currently you declare it static, but then create an instance of the entage class to use it, which defeats the purpose of static.

Also, your class/method names do not follow the generally accepted Java guidelines. Class names should always begin with a capital (e.g. Pear, not pear), and method names should be descriptive of what they will do (eent does not describe what it will do)
 
Vadim Melders
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot! I believe i have sorted it by putting at the end. I just started to learn couple of days and will remember your advice.
 
Vadim Melders
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I made an answer myself is a bit difficult to start with these rules. How can I close this thread..?
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can mark your issue as resolved at the bottom of the page, and a moderator will then confirm the resolution. In this case, I have marked your topic as resolved, but we don't close threads.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to CodeRanch!
 
Vadim Melders
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!