Slot Machine Java Program Code

Permalink

Nov 17, 2010  Hi all, Im new to java this year and have been asked to create a small slot machine program for a project. It is a 3 reel slot machine with a few different combinations of winning. I have came across a few problems when coding this I have listed them below. The program has yet to start up and run. I keep getting these 3 errors and dont no how to fix them. JavaScript Slot machine Code developed By our Skilled Professionals. The modern computerized slot machines have replaced the traditional model, but the basics of the game never change. To get familiar with our JavaScript slot machine technology, you can have a glimpse of the astonishing features provided by our skilled professionals. I'm having issues with a homework problem for my CS class. I'm supposed to make a slot machine and I can't get the continue to work, I get that the scanner nextLine method skips over the line and keeps what was there but it won't let me enter anything and it just ends the program.

Slot Machine Java Program Code Example

Slot Machine Java Program Code

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign upSlot Machine Java Program Code
Find file Copy path

Simple Slot Machine Java Code

Cannot retrieve contributors at this time
/**
* I have neither given nor received unauthorized aid on this assignment.
* Acknowledgements: Thanks to Lucas Perez.
* Eddie Mack
*/
importjava.util.*;
publicclassSlotMachine
{
publicstaticvoidmain (String [] args)
{
Scanner keyboard =newScanner (System.in);
int tokens, pull, afterTokens, wheel1, wheel2, wheel3;
String answer;
tokens =100;
System.out.println ('--Slot Machine--');
System.out.println ('Welcome to Slot Machine! You have 100 tokens. Each pull costs 1 token. Would you like to play? (Y for yes, N for no)');
answer = keyboard.next ();
while (answer.equalsIgnoreCase ('Y'))
{
tokens = tokens -1;
wheel1 = (int) (Math.random () *3) +1;
wheel2 = (int) (Math.random () *3) +1;
wheel3 = (int) (Math.random () *3) +1;
if (wheel1 1&& wheel2 1&& wheel3 1)
{
tokens = tokens +4;
System.out.println ('['+ wheel1 +']'+'['+ wheel2 +']'+'['+ wheel3 +'] You win 4 tokens!!!! You now have '+ tokens +' tokens!');
}
elseif (wheel1 2&& wheel2 2&& wheel3 2)
{
tokens = tokens +8;
System.out.println ('You win 8 tokens!!!! You now have '+ tokens +' tokens!');
}
elseif (wheel1 3&& wheel2 3&& wheel3 3)
{
tokens = tokens +12;
System.out.println ('You win 12 tokens!!!! You now have '+ tokens +' tokens!');
}
else
{
System.out.println ('You lose! You now have '+ tokens +' tokens!');
}
System.out.println ('Would you like to play again? You have '+ tokens +' tokens.');
answer = keyboard.next ();
}
if (answer.equalsIgnoreCase ('N'));
{
System.out.println ('Thanks for playing! You ended with '+ tokens +' tokens!');
}
}
}
  • Copy lines
  • Copy permalink

Slot Machine Java Program Code Tutorial

A 3 reeled slot machine with save functionality.

This GUI Slot Machine made with Swing is supposed to mimic the functionality of a real-life slot machine.
The interface is also designed keeping slot machine design principles in mind. The user first has to bet an amount to start a spin session. To start the game, the 'SPIN!' button must be clicked.

A statistics screen allows users to keep track of highscores of a single playthrough and also save high scores in a text file.

Slot Machine Programs For Pc

Java

Slot Machine Programming Code

Check the wiki page for more details and screenshots