Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

User Input

 
John Murray
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I'm new to java and I found this site as a great resource among other. Right now I'm having some money troubles so I havent had a chance to go out and get a book to buy or buy driving to the library (might be a good thing to just ride my bike and do.) anyways I'm having a bit of toruble working on a new project. The program takes a number the user inputs in the cmd line and prints the square of it, easy enough right? Well it seems I'm having trouble compiling this with netbeans IDE 5.5.1

Here is the source of the origional

here is the compile log

init:
deps-jar:
Created dir: C:\Java\testing2\build\classes
Compiling 1 source file to C:\Java\testing2\build\classes
C:\Java\testing2\src\testing2\Main.java:15: cannot find symbol
symbol : variable TextIO
location: class Square
userInput = TextIO.getInt();
1 error
BUILD FAILED (total time: 1 second)


However the tutorial on this required that I use a file for the TextIO class, how would I go about doing this without that?

Thanks for any help
-John-

[ June 28, 2007: Message edited by: John Murray ]
[ June 28, 2007: Message edited by: John Murray ]
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import the TextIO class or put it in your path? The compiler needs to know where to find TextIO. You could just put it in the same folder as the class you are writing, I am not sure that is the best solution, but it is certainly the easiest.


Where did you get that class? Is it just a wrapper for standard Java IO classes? If it is, I recommend using the standard IO classes from the beginning. These kinds of classes aren't really hiding a whole lot. They are just getting you used to using a non-standard class. Just my opinion. BufferedReader or Scanner should do what you need.
[ June 28, 2007: Message edited by: David McCombs ]
 
John Murray
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NVM had to import class from a diff file from a tutorial(that is why I should just be slapped with a trout), what I meant was how could I get the users input as an integer.
[ June 28, 2007: Message edited by: John Murray ]
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html

or

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some good java tutorials right on the sun java websire
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Vyasu",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
John Murray
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not gunna lie to you, I'm pretty well lost reading all of that between the two links. I fell pretty dumb right now I'm going to go spend some time researching a few words I don't understand in the links. I feel like I can see the bottom of the lake but when I jump in it's actually alot deeper, Might be a fun lake to swim in for awhile though
[ June 28, 2007: Message edited by: John Murray ]
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well!!here comes your answer try the code below you will get user input as integer...

import java.io.BufferedReader;
import java.io.InputStreamReader;



i hope this program gives you the output as square.........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic