• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

User Input

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some good java tutorials right on the sun java websire
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.........
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic