- 7,965
Java Hates me, I swear it. Could somebody help me out with this one. I am required to write a java program that displays a simple Slot machine function. Here's the direct instructions:
I have this so far, but I'm stuck in the mud.
Please help!!!
// *************************************************************************
// Slot Program v1.0
// Programmer: Matt Bertelson
// Date: Feb. 29 2004
// The design behind this program is to select 3 numbers from 0-9 randomly.
// The program repeats itself until the user is done.
// The program also needs to print out appropriate answers for multiples.
// *************************************************************************
import cs1.Keyboard;
public class Slot
{
private Random gen;
public Slot()
{
gen = new Random(); // create random number generator
}
public static void main (String[] args)
{
int a; //first number
int b; //second number
int c; //third number
// Print a program header
System.out.println ();
System.out.println ("Slot Machine");
System.out.println ();
a = gen.nextInt();
b = gen.nextInt();
c = gen.nextInt();
if (a = b = c);
System.out.println ("HOLY COW! You got Triples!!!");
if (a = b);
System.out.println ("You got doubles!");
if (a = c);
System.out.println ("You got doubles!");
if (b = c);
System.out.println ("You got doubles!");
// Print the results
System.out.println ();
System.out.println (a, b, c);
System.out.println ();
}
}
Design and implement an application that simulates a simple slot machine in which three numbers between 0 and 9 are randomly selected and printed side by side. Print an apprpriate statement if all three numbers are the same, or if any two of the numbers are the same. Continue playing until the user chooses to stop.
I have this so far, but I'm stuck in the mud.
// *************************************************************************
// Slot Program v1.0
// Programmer: Matt Bertelson
// Date: Feb. 29 2004
// The design behind this program is to select 3 numbers from 0-9 randomly.
// The program repeats itself until the user is done.
// The program also needs to print out appropriate answers for multiples.
// *************************************************************************
import cs1.Keyboard;
public class Slot
{
private Random gen;
public Slot()
{
gen = new Random(); // create random number generator
}
public static void main (String[] args)
{
int a; //first number
int b; //second number
int c; //third number
// Print a program header
System.out.println ();
System.out.println ("Slot Machine");
System.out.println ();
a = gen.nextInt();
b = gen.nextInt();
c = gen.nextInt();
if (a = b = c);
System.out.println ("HOLY COW! You got Triples!!!");
if (a = b);
System.out.println ("You got doubles!");
if (a = c);
System.out.println ("You got doubles!");
if (b = c);
System.out.println ("You got doubles!");
// Print the results
System.out.println ();
System.out.println (a, b, c);
System.out.println ();
}
}