ADMIN CLASS
/////////////////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
import java.util.Scanner;
import java.util.Formatter;
import java.io.*;
public class Admin extends iiui
implements adm
{
Admin()
{
super();
i2=new Admin[100];
}
public boolean login(String u_name,String password)
{
int ans;
if(password.equals("12345")&&u_name.equals("admin" ))
return true;
else
return false;
}
public void enter_profile()
{
i2[i+1]= new Admin();
Scanner input=new Scanner(System.in);
System.out.print("\n \n\t\t ENTER NAME : ");
i2[i+1].name=input.next();
System.out.print("\n \n\t\tENTER REG # : ");
i2[i+1].reg_no=input.nextInt();
System.out.print("\n \n\t\tENTER FATHER NAME : ");
i2[i+1].f_name=input.next();
System.out.println("\n \t\tENTER SEMESTER : ");
i2[i+1].semester =input.nextInt();
System.out.print("\n \n\t\tENTER AGE : ");
i2[i+1].age=input.nextInt();
System.out.print("\n \n\t\tENTER NATIONALITY : ");
i2[i+1].nationality=input.next();
System.out.print("\n \n\t\tENTER CGPA : ");
i2[i+1].cgpa=input.nextDouble();
System.out.print("\n \n\t\tENTER GRADE : ");
i2[i+1].Grade=input.next();
System.out.print("\n \n\t\tENTER PERCENTAGE : ");
i2[i+1].persentage=input.nextDouble();
i++;
}
public void view_profile()
{
String name;
int reg;
int a,count;
int t=0;
System.out.println("\n \t\t1:View By Name");
System.out.println("\n \t\t2:View By Registration number");
System.out.print("\n \t\tOPTION : ");
Scanner input=new Scanner(System.in);
a=input.nextInt();
switch(a){
case 1:
t=0;
System.out.print("\n \n\t\tENTER NAME : ");
name=input.next();
for(count=0 ; count<=i ; count++)
{
a=0;
if(i2[count].name.equals(name))
{
t++;
a=count;
System.out.print("\n \t\tRegistration number :"+i2[a].reg_no);
System.out.print("\n \t\tName : "+i2[a].name);
System.out.print("\n \t\tFather name : "+i2[a].f_name);
System.out.print("\n \t\tSemester : "+i2[a].semester);
System.out.print("\n \t\tAge : "+i2[a].age);
System.out.print("\n \t\tGrade : "+i2[a].Grade);
System.out.print("\n \t\tcgpa : "+i2[a].cgpa);
System.out.print("\n \t\tPercentage : "+i2[a].persentage);
}
}
if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
break;
case 2:
t=0;
System.out.print("\n \t\tENTER REG #");
reg=input.nextInt();
for(count=0 ;count<=i ;count++)
{
a=0;
if(i2[count].reg_no==reg)
{
t++;
a=count;
System.out.print("\n \t\tRegistration number :"+i2[a].reg_no);
System.out.print("\n \t\tName : "+i2[a].name);
System.out.print("\n \t\tFather name : "+i2[a].f_name);
System.out.print("\n \t\tSemester : "+i2[a].semester);
System.out.print("\n \t\tAge : "+i2[a].age);
System.out.print("\n \t\tGrade : "+i2[a].Grade);
System.out.print("\n \t\tcgpa : "+i2[a].cgpa);
System.out.print("\n \t\tPercentage : "+i2[a].persentage);
}
}
if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
break;
default :
System.out.println("\n \t\tWrong input");
}
}
public void edit_profile()
{
int t=0;
String name,name2,grade;
int regno,age1,semester1,choice=0,ans;
double gpa,persentage1;
Scanner input=new Scanner(System.in);
System.out.println("\n \t\t1:Edit by Name");
System.out.println("\n \t\t2:Edit by Registration number");
System.out.print("\n \t\tOPTION:");
ans=input.nextInt();
switch(ans)
{
case 1:
t=0;
System.out.print("\n \t\tENTER NAME: ");
name=input.next();
for(int j=0 ;j<=i ;j++)
{
int a=0;
if(i2[j].name.equals(name))
{
t++;
a=j;
System.out.print("\n \t\tEnter New Registration number: ");
i2[a].reg_no=input.nextInt();
System.out.print("\n \t\tEnter New Name : ");
i2[a].name =input.next();
System.out.print("\n \t\tEnter New Father name : ");
i2[a].f_name =input.next();
System.out.print("\n \t\tEnter New Age: ");
i2[a].age =input.nextInt();
System.out.print("\n \t\tEnter New Semester : ");
i2[a].semester =input.nextInt();
System.out.print("\n \t\tEnter New Grade : ");
i2[a].Grade =input.next();
System.out.print("\n \t\tEnter New cgpa: ");
i2[a].cgpa =input.nextDouble();
System.out.print("\n \t\tEnter New Percentage : ");
i2[a].persentage =input.nextDouble();
}
}
if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
break;
case 2:
t=0;
System.out.println("\n \t\tENTER REG # : ");
regno=input.nextInt();
for(int j=0 ;j<=i ;j++)
{
if(i2[j].reg_no==regno)
{
t++;
int a=j;
System.out.println("\n \t\tEnter New Registration number");
i2[a].reg_no=input.nextInt();
System.out.println("\n \t\tEnter New Name");
i2[a].name =input.next();
System.out.println("\n \t\tEnter New Father name");
i2[a].f_name =input.next();
System.out.println("\n \t\tEnter New Age");
i2[a].age =input.nextInt();
System.out.println("\n \t\tEnter New Semester");
i2[a].semester =input.nextInt();
System.out.println("\n \t\tEnter New Grade");
i2[a].Grade =input.next();
System.out.println("\n \t\tEnter New cgpa");
i2[a].cgpa =input.nextDouble();
System.out.println("\n \t\tEnter New Percentage");
i2[a].persentage =input.nextDouble();
}
}
if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
break;
}
}
public void enter_result()
{
i2[i+1]= new Admin();
Scanner input=new Scanner(System.in);
System.out.print("\n \t\tENTER NAME : ");
i2[i+1].name=input.next();
System.out.print("\n \t\tENTER REG # : ");
i2[i+1].reg_no=input.nextInt();
System.out.print("\n \t\tENTER CGPA : ");
i2[i+1].cgpa=input.nextDouble();
System.out.print("\n \t\tENTER SEMESTER : ");
i2[i+1].semester=input.nextInt();
System.out.print("\n \t\tENTER PERCENTAGE :");
i2[i+1].persentage=input.nextDouble();
System.out.print("\n \t\tPlease enter Grade : ");
i2[i+1].Grade=input.next();
i++;
}
public void view_result()
{
String n1;
int reg1;
int a,j;
int t=0;
System.out.println("\n \t\t: VEIW RESULT :");
System.out.println("\n \t\t 1:NAME");
System.out.println("\n \t\t 2.REG #");
Scanner input=new Scanner(System.in);
a=input.nextInt();
switch(a){
case 1:
t=0;
System.out.print("\n \t\tENTER NAME : ");
n1=input.next();
for(j=0 ; j<=i ; j++)
{
a=0;
if(i2[j].name.equals(n1))
{
t++;
a=j;
System.out.print("\n \t\t NAME : "+i2[a].name);
System.out.print("\n \t\t GRADE : "+i2[a].Grade);
System.out.print("\n \t\t CGPA : "+i2[a].cgpa);
}
else if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
case 2:
t=0;
System.out.print("ENTER REG #");
reg1=input.nextInt();
for(j=0 ;j<=i ;j++)
{
a=0;
if(i2[j].reg_no==(reg1))
{
t++;
a=i;
System.out.print("\n \t\t NAME : "+i2[a].name);
System.out.print("\n \t\t GRADE : "+i2[a].Grade);
System.out.print("\n \t\t CGPA : "+i2[a].cgpa);
}
else if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
default :
System.out.println("\n \t\twrong input");
}
}
public void edit_result()
{
String e_name,grade;
int r,sir,choice=0;
double gpa;
int t=0;
Scanner input=new Scanner(System.in);
System.out.println("\n \t\t: EDITRESULT :");
System.out.println("\n \t\t1.BY NAME");
System.out.println("\n \t\t2.BY REG #");
System.out.print("\n \t\tOPTION:");
sir=input.nextInt();
switch(sir)
{
case 1:
t=0;
int a=0;
System.out.print("\n \t\tENTER NAME : ");
e_name=input.next();
for(int j=0 ;j<=i ;j++)
{
a=0;
if(i2[j].name.equals(e_name))
{
t++;
a=i;
System.out.print("\n \t\t ENTER NEW GRADE : ");
i2[a].Grade =input.next();
System.out.print("\n \t\t ENTER NEW CGPA");
i2[a].cgpa =input.nextDouble();
}
else if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
case 2:
t=0;
System.out.print("\n \t\t ENTER REG #");
e_name=input.next();
for(int j=0 ;j<=i ;j++)
{
a=0;
if(i2[j].name.equals(e_name))
{
t++;
a=j;
System.out.print("\n \t\t ENTER NEW GRADE : ");
i2[a].Grade =input.next();
System.out.print("\n \t\t ENTER NEW CGPA");
i2[a].cgpa =input.nextDouble();
}
else if(t==0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
}
}
public void writing()
{
if(i>=0)
{
try
{
ObjectOutputStream out=new ObjectOutputStream( new FileOutputStream("islamic.ser"));
for (int j=0 ; j<=i ; j++)
{
System.out.println("working");
out.writeObject(i2[j]);
}
out.close();
// writefile.close();
}
catch(IOException e)
{
System.err.println("File could not be written into");
}
}
try
{
Formatter output=new Formatter("count.txt");
output.format("%10d",i);
output.close();
}
catch(IOException e)
{
System.err.println("Text file could not be written into");
}
}
public void reading()
{
try
{
boolean ans=true;
Scanner counter=new Scanner(new File("count.txt"));
i=counter.nextInt();
if(i>=0)
{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("islamic.ser"));
for(int j=0 ; j<=i ;j++)
{
i2[j]=new Admin();
i2[j]=(Admin) in.readObject();
}
in.close();
}
}
catch(IOException e)
{
System.err.println("File could not be read from");
}
catch ( ClassNotFoundException classNotFoundException )
{
System.err.println( "Unable to create object." );
}
}
public void menu()
{
int option;
do
{
Scanner input=new Scanner(System.in);
int m,ans,choice,count=0,choice1;
System.out.println(" \n \t\tADMINISTRATION ");
System.out.println("\n \t\t1:ENTER PROFILE");
System.out.println("\n \t\t2:VEIW PROFILE");
System.out.println("\n \t\t3:EDIT PROFILE");
System.out.println("\n \t\t4:VEIW RESULT");
System.out.println("\n \t\t5:ENTER RESULT");
System.out.println("\n \t\t6:EDIT RESULT");
System.out.println("\n \t\t7:EXIT");
System.out.print("\n \t\tOPTION : ");
m=input.nextInt();
switch(m)
{
case 1:
enter_profile();
break;
case 2:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
view_profile();
}
break;
case 3:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
edit_profile();
}
break;
case 4:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
view_result();
}
break;
case 5:
enter_result();
break;
case 6:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
edit_result();
}
break;
case 7:
return;
}
System.out.println("\n \t\tDO YOU WANT TO ENTER MORE");
option=input.nextInt();
}while(option==1);
}
}
STUDENT CLASS
///////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
public class Student extends iiui
implements std
{
Student()
{
super();
}
public boolean login(String u_name,String password)
{
int ans;
if(password.equals("123")&&u_name.equals("student" ))
return true;
else
return false;
}
public void profile(iiui i1)
{
String n1;
int reg1;
int a,j;
System.out.println("\n \t\t ENTER NAME : 1");
System.out.println("\n \t\t ENTER REG # : 2");
Scanner input=new Scanner(System.in);
a=input.nextInt();
switch(a){
case 1:
System.out.println("\n \t\t ENTER NAME");
n1=input.next();
for(j=0 ; j<=i ; j++)
{
if(i1.i2[j].name.equals(n1))
{
System.out.print("\n \t\t NAME : "+i1.i2[j].name);
System.out.print("\n \t\t REG # : "+i1.i2[j].reg_no);
System.out.print("\n \t\t FATHER NAME : "+i1.i2[j].f_name);
System.out.print("\n \t\t AGE : "+i1.i2[j].age);
System.out.print("\n \t\t NATIONALITY : "+i1.i2[j].nationality);
System.out.print("\n \t\t CGPA : "+i1.i2[j].cgpa);
System.out.print("\n \t\t GRADE : "+i1.i2[j].Grade);
System.out.print("\n \t\t PERCENTAGE : "+i1.i2[j].persentage);
}
else
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
case 2:
System.out.println("\n \t\t ENTER REG # : ");
reg1=input.nextInt();
for(j=0 ;j<=i ;j++)
{
if(i1.i2[j].reg_no==(reg1))
{
System.out.print("\n \t\t NAME : "+i1.i2[j].name);
System.out.print("\n \t\t GRADE : "+i1.i2[j].Grade);
System.out.print("\n \t\t CGPA : "+i1.i2[j].cgpa);
}
else
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
default :
System.out.println("\n \t\twrong input");
}
}
public void result(iiui i1)
{
String n1;
int reg1;
int a,j;
System.out.print("\n \t\tENTER NAME : 1");
System.out.print("\n \t\t ENTER REG # : 2");
System.out.print("\n \t\tOPTION:");
Scanner input=new Scanner(System.in);
a=input.nextInt();
switch(a){
case 1:
System.out.print("\n \t\t ENTER NAME : ");
n1=input.next();
for(j=0 ; j<=i ; j++)
{
if(i1.i2[j].name.equals(n1))
{
System.out.print("\n \t\t NAME : "+i1.i2[j].name);
System.out.print("\n \t\t GRADE : "+i1.i2[j].Grade);
System.out.print("\n \t\t CGPA : "+i1.i2[j].cgpa);
}
else
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
case 2:
System.out.println("\n \t\tENTER REG # : ");
reg1=input.nextInt();
for(j=0 ;j<=i ;j++)
{
if(i1.i2[j].reg_no==(reg1))
{
System.out.print("\n \t\t NAME : "+i1.i2[j].name);
System.out.print("\n \t\t GRADE : "+i1.i2[j].Grade);
System.out.print("\n \t\t CGPA : "+i1.i2[j].cgpa);
}
else
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
}
break;
default :
System.out.println("\n \t\twrong input");
}
}
public void reading()
{
}
public void writing()
{
}
public void menu2(iiui i1)
{
Scanner input=new Scanner(System.in);
int m,ans,choice,count=0,choice1;
System.out.println("\n \t\tSTUDENT SECTION");
System.out.println("\n \t\t VEIW PROFILE : 1");
System.out.println("\n \t\tVEIW RESULT : 2");
System.out.print("\n \t\tOPTION:");
m=input.nextInt();
switch(m)
{
case 1:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
profile(i1);
}
break;
case 2:
if(i<0)
{
System.out.println("\n \t\t NO DATA PRESENT ");
}
else
{
result(i1);
}
break;
default :
System.out.println("wrong input");
}
}
}
MAIN CLASS
////////////////////////////////////////////////////////////
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
iiui ob1=new Admin();
ob1.reading();
iiui ob=new Student();
int i=0,j=0,option;
boolean ans1;
boolean ans3=false;
String a;
do
{
Scanner input=new Scanner(System.in);
System.out.println(" \t*************************************");
System.out.println("\n \t* ISLAMIC INTERNATIONAL UNIVERSITY * \t\n ");
System.out.println(" \t*************************************");
System.out.println("\n \t\t1: LOG IN");
System.out.println("\n \t\t2: EXIT");
System.out.print("\n \t\tOPTION :");
j=input.nextInt();
switch(j)
{
case 1:
System.out.println("****************************** *************************************");
System.out.println("\n\n\t\tADMINISTRATION : Admin\n\t\t STUDENT : student");
System.out.print("\n\t\tENTER USERNAME :");
String u_name=input.next();
System.out.print("\n\t\tENTER PASSWORD");
String password=input.next();
ans1=ob1.login(u_name, password);
if(ans1==true)
{
System.out.println("\n \t\tWELCOME TO ADMINISTRATION");
}
else
{
ans3=ob.login(u_name,password);
if(ans3==true)
{
System.out.println("\n \t\tWELCOME TO STUDENT SECTION");
}
else
{
System.out.println("\n \t\t\tERROR");
System.out.println("\n \t\tInvalid username and password");
}
}
if((ans1==true)||(ans3==true))
{
System.out.println("\n \t\t1: FBAS");
System.out.println("\n \t\t2: EXIT");
System.out.print("\n \t\tOPTION:");
i=input.nextInt();
if(i==1)
{
System.out.println("\n \t\ta. For DCSSE");
System.out.println("\n \t\tb. For EXIT");
System.out.print("\n \t\tOPTION:");
a=input.next();
switch(a.charAt(0))
{
case 'a':
if(ans1==true)
{
ob1.menu();
break;
}
else
{
ob.menu2(ob1);
break;
}
case 'b':
break;
}
}
}
break;
case 2:
ob1.writing();
// ob.writing();
// ob1.reading();
System.exit(1);
}
System.out.println(" Do You Want To Continue ");
option=input.nextInt();
ob1.writing();
//ob.writing();
}while(option==1);
}
}
////////////////////////////////////////////////////
IIUI CLASS
abstract public class iiui implements adm,std
{
String name,f_name;
int reg_no,age,semester;
double cgpa,persentage;
String Grade, nationality;
iiui i2[];
static int i=-1;
iiui()
{
name=" ";
f_name=" ";
reg_no=0;
age=0;
cgpa=0.0;
Grade=" ";
}
abstract public boolean login(String u_name , String password);
abstract public void reading();
abstract public void writing();
public void menu()
{
}
public void menu2(iiui i1)
{
}
public void enter_profile()
{
}
public void view_profile()
{
}
public void edit_profile()
{
}
public void enter_result()
{
}
public void view_result()
{
}
public void edit_result()
{
}
public void result()
{
}
public void profile()
{
}
}
//////////////////////////////////
ADMIN INTERFACE
/////////////////////////////////////
public interface adm
{
public boolean login(String u_name,String password);
public void enter_profile();
public void view_profile();
public void edit_profile();
public void enter_result();
public void view_result();
public void edit_result();
public void menu();
}
////////////////////////////////
student interface
/////////////////////////////
public interface std
{
public boolean login(String u_name,String password);
public void result();
public void profile();
public void menu2(iiui i1);
}