import java.io.*;
public class CreateEmployees {
public static void main(String [] args)throws IOException{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String str;
String strname;
char gender='m';
char rank='s';
int numemp,numempfull,numemppart,numhours;
boolean goodname;
System.out.print("Enter Number of employees :\t");
str=br.readLine();
numemp=Integer.parseInt(str); //casting a datatype
if(numemp<=0){
System.err.println("Invalid Number of Employees");
System.exit(1);
}
System.out.print("Enter the Number of Employees who are Fulltime:\t ");
str=br.readLine();
numempfull=Integer.parseInt(str);
if ((numempfullnumemp)){
System.err.println("Invalid Number of fulltime Employees");
System.exit(1);
}
//all validation dones so we will declare dynamic arrays now;
numemppart=numemp-numempfull; //no_ of partimers
//using dynamic array
FulltimeEmployee fullemp[]=new FulltimeEmployee[numempfull];
ParttimeEmployee partemp[]=new ParttimeEmployee[numemppart];
for(int i=0;i<numempfull;i++){ //fulltimers
System.out.print("Enter name of Employee "+ (i+1)+" : \t");
str=br.readLine();
strname=str;
goodname=checkstr(strname);
if ((strname.length()<=0) || (!goodname)){ //advance check for name
System.err.println("Invalid name for Employee");
System.exit(1);
}//if
strname=strname.toUpperCase(); //converting to uppercase
System.out.print("Enter the gender of Employee "+ (i+1)+" : \t");
str=br.readLine();
boolean s=(str.equalsIgnoreCase("m") || str.equalsIgnoreCase("f"));
if (!s){ //error checking mechanism
System.err.println("Invalid Gender");
System.exit(1);
}
else if (str.equalsIgnoreCase("m"))
gender='m';
else
gender='f';
System.out.print("Enter Rank of Employee "+(i+1)+" :\t");
str=br.readLine();
boolean r=(str.equalsIgnoreCase("s") || str.equalsIgnoreCase("j"));
if (!r){
System.err.println("Invalid Rank");
System.exit(1);
}
else if (str.equalsIgnoreCase("s"))
rank='s';
else
rank='j';
fullemp[i] = new FulltimeEmployee(strname,gender,rank); //assigning values to object full emp i
System.out.println();
}//for i
System.out.println("Enter Details for parttimers : \n");
for(int j=0;j<numemppart;j++){
System.out.print("Enter name of Employee "+ (j+1)+" : \t");
str=br.readLine();
strname=str;
goodname=checkstr(strname);
if ((strname.length()<=0) || (!goodname)){
System.err.println("Invalid name for Employee");
System.exit(1);
}//if
strname=strname.toUpperCase();
System.out.print("Enter the gender of Employee "+ (j+1)+" : \t");
str=br.readLine();
boolean s=(str.equalsIgnoreCase("m") || str.equalsIgnoreCase("f"));
if (!s){
System.err.println("Invalid Gender");
System.exit(1);
}
else if (str.equalsIgnoreCase("m"))
gender='m';
else
gender='f';
System.out.print("Enter Number of Hours worked by employee "+(j+1)+ " : ");
str=br.readLine();
numhours=Integer.parseInt(str);
if (numhours<=0){
System.err.println("Invalid No of hours");
System.exit(1);
}
partemp[j]=new ParttimeEmployee(strname,gender,numhours);
System.out.println();
}//for j
System.out.println("Here are the Details for full time employees : \n");
for(int k=0;k<numempfull;k++){
fullemp[k].display();
System.out.println("\n");
}
System.out.println("Here are the Details for Parttime time employees : \n");
for(int l=0;l=0 && validated){
for(int j=invalidstr.length()-1;j>=0;j--){
if (str.charAt(i)==invalidstr.charAt(j))
return validated=false;
}//j
i--;
}//while
return validated;
}
}