Untitled

Run Settings
LanguageJava
Language Version
Run Command
// Imports import java.util.Scanner; public class Main{ public static void main(String[] args){ // Scanner Scanner in = new Scanner(System.in); // has user begin the program System.out.println(); System.out.println("Hello welcome to the slot machine program.\nThis program will randomly select 3 numbers from 1-9\nYou will be rewarded points if your numbers match"); int score = 0; System.out.println("Enter y to start "); String start = in.next(); String again; if(start == "y"){ } //random numbers and do while loop do { int num1 = (int) (Math.random()* 10); int num2 = (int) (Math.random()* 10); int num3 = (int) (Math.random()* 10); System.out.println("Your number are"); System.out.println(num1 + " " + num2 + " " + num3); //scoring and main game if(num1 == num2 || num1 == num3|| num2 == num3 ){ score += 100; System.out.println("Two of your numbers match! \nyour balance is " + score); }else if (num1 == num2 && num2 == num3) { score += 500; System.out.println("Three of your numbers match! \nyour balance is " + score); }else{ score -= 5; System.out.println("None of your numbers match. \nyour new balance is " + score); } //loop to ask user if they want to go again System.out.println("\nWould you like to go again! Enter q to quit and y to go again"); again = in.next(); } while(!again.equalsIgnoreCase("q")); //ending System.out.println("Your final added up score is " + score); System.out.println("\nThank you for playing my slot machine game. goodbye!"); } }
Editor Settings
Theme
Key bindings
Full width
Lines