import java.util.*;
import java.text.*;
public class AssignmentNo3
{
static void main (String [] args)
{
//First Digit Variables
int firstD;
//Third Digit Variables lp=licenseplate
String lp;
String abc;
String lpNumS;
String holder;
int letter;
int pos3;
int lpNum;
int thirdD;
char letters;
//Eighth Digit Variables
String dateH;
String month;
String year;
int pos8;
int yNum1;
int yNum2;
int eighthD;
//Last Digit Variables
int lastD;
int sixthD;
//Name changing
String name;
String firstN;
String lastN;
int posN;
//Universal Variables DF == digit final
String regNo;
String firstDF;
String thirdDF;
String eighthDF;
String lastDF;
String secondDF;
String fFDF; //fourth and fifth digit finals
String sixthDF;
String nTEDF; //ninth tenth and eleventh digit finals
String seventhDF;
//Incializing instances of classes / creating objects
Scanner kb = new Scanner(System.in);
Random random = new Random();
Date date = new Date();
SimpleDateFormat dateft = new SimpleDateFormat ("MMM yyyy");
Calendar dateR = Calendar.getInstance();
// Getting user imput
System.out.println ("Enter license plate number (LLL-DDD): ");
lp = kb.nextLine();
System.out.println ("Enter owner's name (fistname lastname: ");
name = kb.nextLine();
//Getting first Digit
firstD = random.nextInt(7)+ 3;
//Getting Third Digit
abc = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lp = lp.toUpperCase();
letters = lp.charAt(1);
letter = abc.indexOf(letters);
pos3 = lp.indexOf("-");
holder = lp.substring(pos3+1);
lpNum = Integer.parseInt(holder);
lpNum = lpNum + letter;
lpNumS = Integer.toString(lpNum);
holder = lpNumS.substring(1,2);
thirdD = Integer.parseInt(holder);
//Getting Eighth digit
dateH = dateft.format(date);
pos8 = dateH.indexOf(" ");
month = dateH.substring(0, pos8);
year = dateH.substring(pos8 +1);
month = month.toUpperCase();
yNum1 = Integer.parseInt(year.substring(2,3));
yNum2 = Integer.parseInt(year.substring(3));
eighthD = (yNum1 + yNum2) % 10;
//Getting Last Digit
sixthD = random.nextInt(10);
lastD = (eighthD + thirdD + sixthD) % 10;
//Coverting Digits to strings and creating remaining digits
firstDF = Integer.toString(firstD);
secondDF = Integer.toString(random.nextInt(10));
thirdDF = Integer.toString(thirdD);
fFDF = Integer.toString(random.nextInt(90)+10);
sixthDF = Integer.toString(sixthD);
seventhDF = Integer.toString(random.nextInt(10));
eighthDF = Integer.toString(eighthD);
nTEDF = Integer.toString(random.nextInt(900)+100);
lastDF = Integer.toString(lastD);
//Changing Name
posN = name.indexOf(" ");
firstN = name.substring(0, posN);
lastN = name.substring(posN+1);
lastN = lastN + ",";
lastN = lastN.substring(0,1).toUpperCase()+lastN.substring(1).toLowerCase();
firstN = firstN.substring(0,1).toUpperCase()+firstN.substring(1).toLowerCase();
name = lastN + " " + firstN;
//Creating the registration number and final touches
regNo = firstDF + secondDF + thirdDF + fFDF + sixthDF + seventhDF + eighthDF + nTEDF + lastDF;
Format renFor = new SimpleDateFormat("MMM yyyy");
dateR.setTime(new Date());
dateR.add(Calendar.YEAR,1);
//Outputting
System.out.println("Imformation for printed registration form:");
System.out.println("");
System.out.println("Registration No. "+regNo);
System.out.println("License Plate No. "+lp);
System.out.println("Owner "+name);
System.out.println("Renewal Month "+renFor.format(dateR.getTime()));
}
}