I've been working on this for a few days now and I'm stuck and burned out. I'm working on a project for a class and trying to create a basic and simple slot machine for my presentation. This is what I have below. What coding am I missing to finish this?
import java.io.PrintStream; import java.util.Random; import java.util.Scanner; public class SlotMachineProject { public static int balance = 0 ; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int play = 0; int cashOut = 0; boolean done = false ; Random generator = new Random(); //Copy the random assignments to slots to inside the loop so you get different "pulls" of the machine each time int slot1 = generator.nextInt(10); int slot2 = generator.nextInt(10); int slot3 = generator.nextInt(10); System.out.println("Your Current Balance is: " + balance); // I think conditions in a while are confusing. I would I simplify it to this: // // while ( !done ) // // Then set boolean variable done correctly within the loop using if on cashOut. // while ((cashOut > 0) || (play <= 0)) { // stop playing immediately without looping System.out.println("\nType 1 to start the slot machine or 0 to stop playing."); cashOut = scan.nextInt(); // I need to put in an if to set done = true when cashOut is 0. // I'm confused. I put spaces in here so that it is clear that it is more than // one number being printed. System.out.println("Result is: " + slot1 + "," + slot2 + " " + slot3); if ((slot1 == slot2) && (slot1 == slot3)) { // I need to change balance, play or both here to reflect winnings. System.out.println("Congradulations, you have won: " + play); System.out.println("\nCurrent Balance is: " + (play + balance)); } else if (((slot1 == slot2) && (slot1 != slot3)) || ((slot2 == slot3) && (slot2 != slot1)) || ((slot3 == slot1) && (slot3 != slot2))) { System.out.println("Congradulations, you have won." + play); System.out.println("\nCurrent Balance is: " + (play + balance)); } else if ((slot1 != slot2) && (slot1 != slot3) && (slot2 != slot3)) { System.out.println("\nCurrent Balance is: " + (cashOut - balance)); } } } }