void methods in Java. showIntro(), displayMenu(), and gameOver(). main(), call these methods in sequence. import java.util.Scanner;
public class Program{ public static void main(String[] args) { Scanner input = new Scanner(System.in); String choice;
showIntro(); displayMenu();
// To Do: Menu System }
static void showIntro() { System.out.println("=== MINI GAME COLLECTION VOL. 1 ==="); System.out.println("Welcome!"); System.out.println(); }
static void displayMenu() { System.out.println("1. Guess the Number"); System.out.println("2. Lucky Dice"); System.out.println("3. Spin the Wheel"); System.out.println("4. Exit"); System.out.println(); }
static void gameOver() { System.out.println("Thanks for playing!"); System.out.println("Goodbye!"); }}import java.util.Scanner;
public class Program{ public static void main(String[] args) { Scanner input = new Scanner(System.in); String choice;
showIntro(); // move displayMenu() into the loop
do { displayMenu(); System.out.print("Choose mini-game: "); choice = input.nextLine();
switch (choice) { case "1" -> playGuessTheNumber(); case "2" -> playLuckyDice(); case "3" -> playSpinTheWheel(); case "4" -> gameOver(); default -> System.out.println("Invalid choice."); }
System.out.println();
} while (!choice.equals("4")); }
static void showIntro() {3 collapsed lines
System.out.println("=== MINI GAME COLLECTION VOL. 1 ==="); System.out.println("Welcome!"); System.out.println(); }
static void displayMenu() {5 collapsed lines
System.out.println("1. Guess the Number"); System.out.println("2. Lucky Dice"); System.out.println("3. Spin the Wheel"); System.out.println("4. Exit"); System.out.println(); }
static void gameOver() {2 collapsed lines
System.out.println("Thanks for playing!"); System.out.println("Goodbye!"); }
static void playGuessTheNumber() { // To Do: Guess the Number Mini-Game }
static void playLuckyDice() { // To Do: Lucky Dice Mini-Game }
static void playSpinTheWheel() { // To Do: Spin the Wheel Mini-Game }}import java.util.Scanner;
public class Program{ public static void main(String[] args) {24 collapsed lines
Scanner input = new Scanner(System.in); String choice;
showIntro();
do { displayMenu(); System.out.print("Choose mini-game: "); choice = input.nextLine();
switch (choice) { case "1" -> playGuessTheNumber(); case "2" -> playLuckyDice(); case "3" -> playSpinTheWheel(); case "4" -> gameOver(); default -> System.out.println("Invalid choice."); }
System.out.println();
} while (!choice.equals("4")); }
static void showIntro() {3 collapsed lines
System.out.println("=== MINI GAME COLLECTION VOL. 1 ==="); System.out.println("Welcome!"); System.out.println(); }
static void displayMenu() {5 collapsed lines
System.out.println("1. Guess the Number"); System.out.println("2. Lucky Dice"); System.out.println("3. Spin the Wheel"); System.out.println("4. Exit"); System.out.println(); }
static void gameOver() {2 collapsed lines
System.out.println("Thanks for playing!"); System.out.println("Goodbye!"); }
static void playGuessTheNumber() { Scanner input = new Scanner(System.in);
System.out.println("--- Guess the Number ---"); System.out.print("Guess my secret number betwen 1 and 10: "); int secret = (int)((Math.random() * 10) + 1); int guess = input.nextInt();
System.out.println("It was " + secret + "!"); System.out.println(guess == secret ? "You Win!" : "You Lose!"); }
static void playLuckyDice() { Scanner input = new Scanner(System.in); int die1 = (int)((Math.random() * 6) + 1); int die2 = (int)((Math.random() * 6) + 1); int bet;
System.out.println("--- Lucky Dice ---"); System.out.println(); }
static void playSpinTheWheel() { Scanner input = new Scanner(System.in); int wheel = (int)((Math.random() * 25) + 1); int bet;
System.out.println("--- Spin the Wheel ---"); System.out.println(); }}Your program output should look similar to the sample output below.
=== MINI GAME COLLECTION VOL. 1 ===Welcome!
1. Guess the Number2. Lucky Dice3. Spin the Wheel4. Exit
Choose mini-game: 1--- Guess the Number ---Guess my secret number betwen 1 and 10: 7It was 7!You Win!
1. Guess the Number2. Lucky Dice3. Spin the Wheel4. Exit
Choose mini-game: 4Thanks for playing!Goodbye!You may write your reflection answers as comments at the bottom of your code.
main()?
Submit your completed .java file and reflection answers to the
appropriate dropbox.