Java Program to display the details of a Person using User Defined Package | IT2305 - Java Programming Lab


AIM:
To write a Java program to display the details of a person using User Defined Package in IT2305 - Java Programming Laboratory.

SOURCE CODE:
import person.Studen;
import person.Employee;
import static java.lang.System.*;
import java.util.*;
import java.io.*;
public class StudEmp
{
public static void main(String args[])
{
int i,n,no,no1;
Boolean k,k1;
Console cons=System.console();
String username=cons.readLine("user name:");
char[] passwd=cons.readPassword("password:");
String s1="08cs083";
char[] pwd={'w','x','y','z'};
k=s1.equals(username);
k1=Arrays.equals(passwd,pwd);
if(k==true&& k1==true)
{

out.println("enter ur choice");
out.println("1.student details\n2.employee details\n");
Scanner sin=new Scanner(in);
n=sin.nextInt();
switch(n)
{
case 1:
       out.println("enter the no of students");
       no=sin.nextInt();
        Studen s[]=new Studen[no];
       for(i=0;i<s.length;i++)
       {
        s[i]=new Studen();
       }
       for(i=0;i<s.length;i++)
       {
          s[i].readData();
       }
       for(i=0;i<s.length;i++)
       {
          s[i].printDetails();
       }
      break;
case 2:
       out.println("enter the no of employees:");
       no1=sin.nextInt();
        Employee e1[]=new Employee[no1];
       for(i=0;i<e1.length;i++)
        {
         e1[i]=new Employee();
        }
       for(i=0;i<e1.length;i++)
       {
         e1[i].readDetails();
       }
       for(i=0;i<e1.length;i++)
       {
         e1[i].print_Data();
       }
       break;
    }
  }
}
Previous
Next Post »

Still not found what you are looking for? Try again here.