Re: help needed on inputting - tearing hair out .. please!!!
- From: "patrick_woflian" <gingercrock@xxxxxxxxxxx>
- Date: 28 Nov 2005 09:32:39 -0800
import java.util.Scanner;
import java.util.Random;
public class dice
{
public static void main (String [] args)
{
Scanner in = new Scanner(System.in);
Random rnd = new Random();
int correctguesses;
correctguesses = 0;
int r = rnd.nextInt(12) + 1;
System.out.print("guess a number ");
int x = in.nextInt();
if (x != r)
System.out.print(" Do you think the next number will be higher HI or
lower LO than " + x );
int y = in.nextInt();
String guess = in.next();
boolean correct = false;
if (guess.equals("HI"))
{
correct = ( x > y);
}
else if (guess.equals("LO"))
{
correct = (x < y);
}
System.out.println("The number was " + x + " and you guessed " + y +
" so you " + (correct ? "ROCK!" : "SUCK!"));
}
}
this is the program in its full, i am trying to capture input from the
text file.. thanks very much for your help
patrick
.
- Follow-Ups:
- Re: help needed on inputting - tearing hair out .. please!!!
- From: Oliver Wong
- Re: help needed on inputting - tearing hair out .. please!!!
- From: Michael Redlich
- Re: help needed on inputting - tearing hair out .. please!!!
- From: Roedy Green
- Re: help needed on inputting - tearing hair out .. please!!!
- References:
- help needed on inputting - tearing hair out .. please!!!
- From: patrick_woflian
- Re: help needed on inputting - tearing hair out .. please!!!
- From: Michael Redlich
- help needed on inputting - tearing hair out .. please!!!
- Prev by Date: Re: cant's compile with javac
- Next by Date: Re: help needed on inputting - tearing hair out .. please!!!
- Previous by thread: Re: help needed on inputting - tearing hair out .. please!!!
- Next by thread: Re: help needed on inputting - tearing hair out .. please!!!
- Index(es):