Code
Code
Scanner;
do {
System.out.println("\n--- Hotel Management System ---");
System.out.println("1. Book a Room");
System.out.println("2. Check Out");
System.out.println("3. Exit");
System.out.print("Enter your choice (1-3): ");
choice = sc.nextInt();
sc.nextLine(); // Consume the newline character
switch (choice) {
case 1:
bookRoom(sc);
break;
case 2:
checkout(sc);
break;
case 3:
System.out.println("Thank you for using the Hotel Management
System. Goodbye!");
break;
default:
System.out.println("Invalid choice. Please try again.");
}
} while (choice != 3);
sc.close();
}
String paymentDetails;
if (paymentOption == 1) {
paymentDetails = "Paid via Cash";
} else if (paymentOption == 2) {
System.out.print("Enter your UPI ID: ");
String upiId = sc.nextLine();
paymentDetails = "Paid via UPI (ID: " + upiId + ")";
} else {
System.out.println("Invalid payment option. Booking canceled.");
return;
}