Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read as integer...

Posted on 1998-05-06
2
Medium Priority
?
173 Views
Last Modified: 2010-04-16
OK, I want to have an interface to read a keyboard input to be understood as integer or double, to perform some calculation upon that number. What's the easiest way to do it ?
0
Comment
Question by:ggmg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
fontaine earned 150 total points
ID: 1220597
System.in provides you with an InputStream to read data from the standard input stream, i.e. the keyboard. As you need a higher level of abstraction, build a DataInputStream upon it and use its readInt(), readByte(), etc., methods

Example:

DataInputStream in = new DataInputStream(System.in);

try {
int anInt = in.readInt();
double aDouble = in.readDouble();
} catch (IOException e) {
e.printStackTrace();
 }
0
 

Author Comment

by:ggmg
ID: 1220598
Thanks a lot...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question