I am a beginner in coding and I need to write a program in Java where a restaurant admin can input a date (January 10, 2022) for until when customer can book reservation at their restaurant and when a customer wants to book the restaurant after the date input by the admin (February 12, 2022), the customer needs to choose another date (it must be before or at January 10, 2022).
I read about the calendar class and time class, but still cannot figure it out. How do I do it? I am sorry I cannot show even the smallest part of my code about this program because I really don't know what to do.
import java.util.*;
public class BookRestaurant{
public static void main(String[] args){
Scanner key = new Scanner(System.in);
String uName;
String password;
String dateByAdmin;
String dateByCust;
System.out.print("Enter username: ");
uName = key.nextLine();
System.out.print("Enter password: ");
password = key.nextLine();
switch (uName){
case "admin":
System.out.print("Enter until what date restaurant open(mm/dd/yyyy): ");
dateByAdmin = key.nextLine();
break;
case "user":
System.out.print("Enter book date(mm/dd/yyyy): ");
dateByCust = key.nextLine();
//this is where the customer need to get asked to enter another date
break;
}
System.out.print("Thank You");
}
}