User Input
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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 ]
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 ]
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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 ]
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
John Murray
Greenhorn
Posts: 3
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
[ June 28, 2007: Message edited by: John Murray ]
David McCombs
Ranch Hand
Posts: 212
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
or
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"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
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
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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 ]
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.........
import java.io.BufferedReader;
import java.io.InputStreamReader;
i hope this program gives you the output as square.........

| It will give me the powers of the gods. Not bad for a tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |







