
Hello Subash!
Here is the solution for the question you are asking for, I solved it in procedural way but if you are among the one who prefer OOP style then you can still ask it for me cause I have solved it from both methods but here I am just going to leave procedural one....
//author:Manish Acharya
import java.util.Scanner;
import java.util.*;
public class idgenerator {
public static void main(String[] args) {
String small_name="", long_name="", new_small_name="", new_long_name="";
char lr='a',...

BODMAS=Bracket, Order, Division, Multiplication, Addition and Subtraction. In certain regions, PEMDAS (Parentheses, Exponents, Multiplication, Division, Addition and Subtraction) is the synonym of BODMAS. It explains the order of operations to solve an expression.

1. sol:
P | q | ~p | ~p ^ q |
T T F F | T F T F | F F T T | F F T F |