• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner in Java needs help  RSS feed

 
Ted O Brien
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator






On the line
System.out.print("\n\nEnter Score " + (i+1) + ": ");
scores[i] = UserInput.getInt();

I am getting an error with the UserInput.getInt(); and I have no idea why
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Where is UserInput declared? Is it a class? Is it a variable somewhere?

Henry
 
Ted O Brien
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think its declared anywhere, i really have no idea to be honest. I just want to read the user input so i can store the numbers, if thats correct?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam Notarobot wrote:I dont think its declared anywhere, i really have no idea to be honest.


There is *no* built-in UserInput class, variable, method, etc. So, if you didn't declare it, and you didn't get it from anywhere, then it doesn't exist. And that is why you got a compiler error.

Henry
 
Ted O Brien
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so how do I read the user input and store the numbers. I thought it would basically be the same thing as reading the players names no?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam Notarobot wrote:I thought it would basically be the same thing as reading the players names no?


Yes, you can do it the same way. Read the value in as a string, just like player names, and then parse it to a number.

Henry
 
Ted O Brien
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i got it to read the user input, now to just display lowest,highest,average
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags (that's a link) when you're posting code.  It makes it much easier to read.  I've done it for you this time.
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The comment says this code gets six names, but it doesn't; it only saves the last name.  Use an array the same way you used it for scores.
 
Ted O Brien
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I honestly have no idea, ive been searching online all day and still have gotten no further
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See line 31 for an example of how to store data in an array.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!