3 Replies - 6559 Views - Last Post: 12 September 2005 - 06:24 PM Rate Topic: -----

#1 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

input from key board

Posted 22 August 2005 - 09:01 AM

Im am new to java and i can not find out how to get input from the keyboard in a consol application.

For Example:

Would you like to run this program?
Type yes or no and press enter.


how would i get the yes or no?
Is This A Good Question/Topic? 0
  • +

Replies To: input from key board

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: input from key board

Posted 22 August 2005 - 11:24 AM

There are many ways to do it...but here is one...

http://fog.ccsf.cc.c...1b/NotesIO.html
Was This Post Helpful? 1

#3 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

Re: input from key board

Post icon  Posted 25 August 2005 - 09:24 AM

Thank you so much for your help!!

This post has been edited by Drift-O-Manaic: 26 August 2005 - 08:16 AM

Was This Post Helpful? 0
  • +
  • -

#4 cap10kid3  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 36
  • Joined: 16-August 05

Re: input from key board

Posted 12 September 2005 - 06:24 PM

here is another example of how to do it
import java.io.*;
import java.lang.*;
public class RandomStuff
{
public static void playGame() throws IOException
{
try{

String Yorn;

BufferedReader keyboard;
boolean loopNeeded;

keyboard = new BufferedReader(new InputStreamReader(System.in));

System.out.println ("Would you like to play the game? \n Type Y or N and press Enter");
Yorn = keyboard.readLine();

if (Yorn.equalsIgnoreCase("y"))
enterChar();
else if (Yorn.equalsIgnoreCase("n"))
System.exit(1);

else
{
System.out.println ("Follow Directions!");



}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1