My task is to code a small program that would calculate an administrator access code that changes daily based on a predefined algorithm (month * day * constant).
I have the gist of the code written for my main method with the basic functionality pulling from java.time.LocalDate & format.DateTimeFormatter and then parsing the string into an integer and then calculating and displaying the results.
String month = DateTimeFormatter.ofPattern("MM").format(localDate);
String date = DateTimeFormatter.ofPattern("dd").format(localDate);
int monthResult = Integer.parseInt(month);
int dateResult = Integer.parseInt(date);
int adminAccess = monthResult * dateResult * seed;
System.out.println("Admin Passcode is: " + adminAccess);
But now I want to take this to the next level and incorporate an option to calculate the access code manually via user input.
I want to validate the user input and allow numeric or string input before taking the input and assigning the correct integer representation based on their input. I'm looking to ultimately do something along these lines (Anticipated Program Flow) 1. I'm not sure if I'm just too far above my head, but I can't quite wrap my mind around what functionality I should use a For, Do While or a Switch to process the validation. All I have right now is:
class userManual {
public void run() {
String [] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
String [] numMonths = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
Scanner scan = new Scanner(System.in);
String manual = scan.next();
for () {}
}
}
Any ideas would be greatly appreciated!!