Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement an Java application that simulates a simple slot machine in

ID: 3814776 • Letter: D

Question

Design and implement an Java application that simulates a simple slot machine in which three numbers between 0 and 9 are randomly selected and printed side by side. The user should be asked if they want to play and how many tokens they want to put into the machine. Your game should continually ask the user if they want to play ("y" and "n") and check to see if they have enough tokens to play. Every time the user plays you should subtract a certain amount of tokens. Display the results for each play and based on the results of your random numbers reward the player accordingly. When the player is finished playing (either by choice or having run out of tokens) provide a message thanking them for playing, displaying their token amount, and asking them to come back.( I don't have any more information)

Explanation / Answer

import java.util.Random;
import java.util.Scanner;

public class Game {
public static void main (String [] args){
   int randomNum = 0;
   int randomNum1 = 0;
   int randomNum2 = 0;

System.out.println("You Want to Start the Game? Enter 'Y' for yes and 'N' for No.");
Scanner scan = new Scanner (System.in);
String answer = scan.nextLine();
if ( "Y".equals(answer)){
System.out.println("Enter tokens between 1-10");
Scanner scan1 = new Scanner (System.in);
int Tokens = scan1.nextInt();
  
for(int j=0;j<=Tokens;j--){
   if(Tokens>=3){
   Random rand = new Random();

   randomNum = rand.nextInt((9-1) + 1) + 1;
   randomNum1 = rand.nextInt((9-1) + 1) + 1;
   randomNum2 = rand.nextInt((9-1) + 1) + 1;
   System.out.println("Total tokens left:"+Tokens);
   System.out.println("Here are your Numbers->" +randomNum+":"+randomNum1+":"+randomNum2);
   if(Tokens>3){
       System.out.println("Again the numbers will be genertaed.");
   }
  
   Tokens = Tokens -3;
  
}
  
}
if(Tokens < 3){
        System.out.println("Tokens left:"+Tokens+" You are short of Tokens.Enter tokens between 1-10 to play again. Or Enter 'Bye' to end the Game.");
        Scanner scan3 = new Scanner (System.in);
    String answer3 = scan3.nextLine();
    if(answer3.equalsIgnoreCase("Bye")){
        System.out.println("Thank for playing the Game.");
    }
    }

}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote