You are on page 1of 1

import java.util.

Scanner;

public class Betting {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Prompt the user to enter their age


System.out.print("Enter your age: ");
int age = scanner.nextInt();

// Check the user's age and throw an exception if it's below 18


if (age < 18) {
System.out.println("Access denied");
scanner.close();
return;
}

// Clear the newline character from the buffer


scanner.nextLine();

// Prompt the user to enter their name


System.out.print("Enter your name: ");
String name = scanner.nextLine();

// Prompt the user to enter their telephone number


System.out.print("Enter your telephone number: ");
String phoneNumber = scanner.nextLine();

// Display the entered information


System.out.println("Access granted");
System.out.println("Age: " + age);
System.out.println("Name: " + name);
System.out.println("Telephone Number: " + phoneNumber);

// Close the scanner


scanner.close();
}
}

You might also like