import java.util.Random; import java.util.Scanner; public class Main { public static void main(String[] args) { // Create a scanner object for user input Scanner scanner = new Scanner(System.in); // Create a random object for generating random numbers Random random = new Random(); System.out.println("Welcome to the Dice Game!"); // Start a loop for the game while (true) { // Wait for the user to press Enter to roll the dice System.out.println("Press Enter to roll the dice..."); scanner.nextLine(); // Wait for the user to press Enter // Generate a random number between 1 and 10 int roll = random.nextInt(100) + 1; System.out.println("You rolled a " + roll + "!"); // Ask the user if they want to play again System.out.print("Do you want to roll again? (y/n): "); String playAgain = scanner.nextLine().toLowerCase(); // If the user does not want to play again, break the loop if (!playAgain.equals("y")) { System.out.println("Thanks for playing! Goodbye."); break; } } // Close the scanner scanner.close(); } }