Person (Name, address, phone no, unique id) Customer (Customer id, account no, type of account, current balance) Employee (Employee id, Joining date, Salary, department id) Staff (Staff id) Manager (Manager id, number of staffs under the manager) Bank branch (Name, Branch Id, list of customers, list of departments) Department (department id, List of employees) Assume there is at most one manager in each department. Write a menu driven program to perform the following operations: 1. Add a bank branch. (You need to call this only once in the beginning) 2. Add a department. 3. Add a Customer/Employee/Staff/Manager in the database 4. Display information of a Customer/Employee/Staff/Manager 5. Display a department. 6. Delete a staff information (if staff is deleted then it should also be updated in the corresponding department.). 7. Delete a manager information. 8. Increase the salary of all employees (10% for staff and 20% for manager) who are working in a given department. 9. Assign a given existing staff to a given manager.. 10. Promoting a staff to a manager. 11. Change the department of a staff (if the department is changed then the staff is shifted automatically under the manager of the changed department if any) 12. Compute average salary of the employees in the bank in java

import java.io.*;

import java.util.ArrayList;

public class LabAssign7

{

    public static void main(String[] args) throws IOException

    {

        int z;

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        ArrayList<Department> OBJ1=new ArrayList<Department>();

        ArrayList<Customer> OBJ2=new ArrayList<Customer>();

        ArrayList<Staff> OBJ3=new ArrayList<Staff>();

        ArrayList<Manager> OBJ4=new ArrayList<Manager>();

        System.out.println("Enter bank name and branch id");

        String name1=br.readLine();

        String branchid=br.readLine();

        Bank obj=new Bank(name1,branchid);

        do

        {

            System.out.println("Enter 1 to add a department");

            System.out.println("Enter 2 to add a Customer/Staff/Manager in the database");

            System.out.println("Enter 3 to display information of a Customer/Staff/Manager");

            System.out.println("Enter 4 to display a department");

            System.out.println("Enter 5 to delete a staff information");

            System.out.println("Enter 6 to delete a manager information");

            System.out.println("Enter 7 to increase the salary of all employees (10% for staff and 20% for manager) who are working in a given department");

            System.out.println("Enter 8 to assign a given existing staff to a given manager");

            System.out.println("Enter 9 to promote a staff to a manager where already a previos manager exits");

            System.out.println("Enter 10 to change the department of a staff");

            System.out.println("Enter 11 to compute average of all the employees in the bank");

            int a=Integer.parseInt(br.readLine());

            switch(a)

            {

                case 1:

                {

                    System.out.println("Enter its department id");

                    String depid=br.readLine();

                    Department obj1=new Department(depid);

                    OBJ1.add(obj1);

                    (obj.tdepart).add(depid);

                    break;

                }

                case 2:

                {

                    int j,t=0;

                    System.out.println("Enter 1 for Customer, 2 for Staff, 3 for Manager");

                    int i=Integer.parseInt(br.readLine());

                    if(i==1)

                    {

                        System.out.println("Enter Name, address, phone no, unique id, Customer id, account no, type of account, current balance");

                        String name=br.readLine();

                        String address=br.readLine();

                        String phoneno=br.readLine();

                        String id=br.readLine();

                        String cusid=br.readLine();

                        String acno=br.readLine();

                        String tyacc=br.readLine();

                        String bal=br.readLine();

                        Customer obj2=new Customer(name,address,phoneno,id,cusid,acno,tyacc,bal);

                        (obj.tcust).add(id);

                        OBJ2.add(obj2);

                    }

                    if(i==2)

                    {

                        System.out.println("Enter Name, address, phone no, unique id,Employee id, Joining date, Salary, department id,staff id");

                        String name=br.readLine();

                        String address=br.readLine();

                        String phoneno=br.readLine();

                        String id=br.readLine();

                        String empid=br.readLine();

                        String jodate=br.readLine();

                        Double salary=Double.parseDouble(br.readLine());

                        String depid=br.readLine();

                        String staid=br.readLine();

                        Staff obj3=new Staff(name,address,phoneno,id,empid,jodate,salary,depid,staid);

                        for(j=0;j<OBJ1.size();j++)

                        {

                            if(depid.equals((OBJ1.get(j)).depid))

                            {

                                ((OBJ1.get(j)).templ).add(id);

                            }

                        }

                        OBJ3.add(obj3);

                    }

                    if(i==3)

                    {

                        System.out.println("Enter Name, address, phone no, unique id,Employee id, Joining date, Salary, department id, Manager id");

                        String name=br.readLine();

                        String address=br.readLine();

                        String phoneno=br.readLine();

                        String id=br.readLine();

                        String empid=br.readLine();

                        String jodate=br.readLine();

                        double salary=Double.parseDouble(br.readLine());

                        String depid=br.readLine();

                        String manid=br.readLine();

                        for(j=0;j<OBJ1.size();j++)

                        {

                            if(depid.equals((OBJ1.get(j)).depid))

                            {

                                ((OBJ1.get(j)).templ).add(id);

                                t=j;

                            }

                        }

                        Manager obj4=new Manager(name,address,phoneno,id,empid,jodate,salary,depid,manid,(((OBJ1.get(t)).templ).size()-1));

                        OBJ4.add(obj4);

                    }

                    break;

                }

                case 3:

                {

                    int j,k;

                    String s=null;

                    System.out.println("Enter the unique id");

                    String id=br.readLine();

                    for(j=0;j<OBJ2.size();j++)

                    {

                        if(id.equals((OBJ2.get(j)).id))

                        {

                            System.out.println("NAME:"+((OBJ2.get(j)).name));

                            System.out.println("ADDRESS:"+((OBJ2.get(j)).address));

                            System.out.println("PHONE NO:"+((OBJ2.get(j)).phoneno));

                            System.out.println("UNIQUE ID:"+((OBJ2.get(j)).id));

                            System.out.println("CUSTOMER ID:"+((OBJ2.get(j)).cusid));

                            System.out.println("ACCOUNT NO:"+((OBJ2.get(j)).acno));

                            System.out.println("ACCOUNT TYPE:"+((OBJ2.get(j)).tyacc));

                            System.out.println("NET BALANCE:"+((OBJ2.get(j)).bal));

                        }

                    }

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id.equals((OBJ3.get(j)).id))

                        {

                            System.out.println("NAME:"+((OBJ3.get(j)).name));

                            System.out.println("ADDRESS:"+((OBJ3.get(j)).address));

                            System.out.println("PHONE NO:"+((OBJ3.get(j)).phoneno));

                            System.out.println("UNIQUE ID:"+((OBJ3.get(j)).id));

                            System.out.println("EMPLOYMENT ID:"+((OBJ3.get(j)).empid));

                            System.out.println("JOINING DATE:"+((OBJ3.get(j)).jodate));

                            System.out.println("SALARY:"+((OBJ3.get(j)).salary));

                            System.out.println("DEPARTMENT ID:"+((OBJ3.get(j)).depid));

                            System.out.println("STAFF ID:"+((OBJ3.get(j)).staid));

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(id.equals((OBJ4.get(j)).id))

                        {

                            System.out.println("NAME:"+((OBJ4.get(j)).name));

                            System.out.println("ADDRESS:"+((OBJ4.get(j)).address));

                            System.out.println("PHONE NO:"+((OBJ4.get(j)).phoneno));

                            System.out.println("UNIQUE ID:"+((OBJ4.get(j)).id));

                            System.out.println("EMPLOYMENT ID:"+((OBJ4.get(j)).empid));

                            System.out.println("JONING DATE:"+((OBJ4.get(j)).jodate));

                            System.out.println("SALARY:"+((OBJ4.get(j)).salary));

                            s=((OBJ4.get(j)).depid);

                            System.out.println("DEPARTMENT ID:"+((OBJ4.get(j)).depid));

                            System.out.println("MANAGER ID:"+((OBJ4.get(j)).manid));

                            for(k=0;k<OBJ1.size();k++)

                            {

                                if(s.equals((OBJ1.get(k)).depid))

                                    {

                                        (OBJ4.get(j)).tstaff=(((OBJ1.get(k)).templ).size()-1);

                                    }

                            }

                            System.out.println("TOTAL STAFF:"+((OBJ4.get(j)).tstaff));

                        }

                    }

                    break;

                }

                case 4:

                {

                    int j,k;

                    System.out.println("Enter the department id");

                    String depid=br.readLine();

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(depid.equals((OBJ1.get(j)).depid))

                        {

                            System.out.println("Department ID:"+(OBJ1.get(j)).depid);

                            System.out.println("Employees ID in the above department");

                            for(k=0;k<((OBJ1.get(j)).templ).size();k++)

                            {

                                System.out.println(((OBJ1.get(j)).templ).get(k));

                            }

                        }

                    }

                    break;

                }

                case 5:

                {

                    int j;

                    String s=null;

                    System.out.println("Enter the unique id of the staff whose information needs to be deleted");

                    String id=br.readLine();

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id.equals((OBJ3.get(j)).id))

                        {

                            s=((OBJ3.get(j)).depid);

                            OBJ3.remove(j);

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(s.equals((OBJ1.get(j)).depid))

                        {

                            ((OBJ1.get(j)).templ).remove(id);

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(s.equals((OBJ4.get(j)).depid))

                        {

                            (OBJ4.get(j)).tstaff--;

                        }

                    }

                    break;

                }

                case 6:

                {

                    int j;

                    String s=null;

                    System.out.println("Enter the unique id of the manager whose information needs to be deleted");

                    String id=br.readLine();

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(id.equals((OBJ4.get(j)).id))

                        {

                            s=((OBJ4.get(j)).depid);

                            OBJ3.remove(j);

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(s.equals((OBJ1.get(j)).depid))

                        {

                            ((OBJ1.get(j)).templ).remove(id);

                        }

                    }

                    break;

                }

                case 7:

                {

                    int j;

                    System.out.println("Enter the department id");

                    String depid=br.readLine();

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(depid.equals((OBJ3.get(j)).depid))

                        {

                            ((OBJ3.get(j)).salary)=(1.1*((OBJ3.get(j)).salary));

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(depid.equals((OBJ4.get(j)).depid))

                        {

                            ((OBJ4.get(j)).salary)=(1.2*((OBJ4.get(j)).salary));

                        }

                    }

                    break;

                }

                case 8:

                {

                    int j,k;

                    String s1=null,s2=null;

                    System.out.println("Enter the unique id of the staff and the manager");

                    String id1=br.readLine();

                    String id2=br.readLine();

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id1.equals((OBJ3.get(j)).id))

                        {

                            s1=((OBJ3.get(j)).depid);

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(id2.equals((OBJ4.get(j)).id))

                        {

                            ((OBJ4.get(j)).tstaff)++;

                            s2=(OBJ4.get(j)).depid;

                        }

                        if(s1.equals((OBJ4.get(j)).depid))

                        {

                            ((OBJ4.get(j)).tstaff)--;

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(s1.equals((OBJ1.get(j)).depid))

                        {

                            for(k=0;k<((OBJ1.get(j)).templ).size();k++)

                            {

                                if(id1.equals(((OBJ1.get(j)).templ).get(k)))

                                {

                                    ((OBJ1.get(j)).templ).remove(id1);

                                }

                            }

                        }

                    }

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id1.equals((OBJ3.get(j)).id))

                        {

                            ((OBJ3.get(j)).depid)=s2;

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(s2.equals((OBJ1.get(j)).depid))

                        {

                            ((OBJ1.get(j)).templ).add(id1);

                        }

                    }

                    break;

                }

                case 9:

                {

                    int j;

                    String name=null,address=null,phoneno=null,id=null,empid=null,jodate=null;

                    String depid=null;

                    int tstaff=0;

                    String id2=null;

                    System.out.println("Enter the staff unique id");

                    String id1=br.readLine();

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id1.equals(((OBJ3.get(j)).id)))

                        {

                            name=((OBJ3.get(j)).name);

                            address=((OBJ3.get(j)).address);

                            phoneno=((OBJ3.get(j)).phoneno);

                            id=((OBJ3.get(j)).id);

                            empid=((OBJ3.get(j)).empid);

                            jodate=((OBJ3.get(j)).jodate);

                            depid=((OBJ3.get(j)).depid);

                            OBJ3.remove(j);

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(depid.equals((OBJ4.get(j)).depid))

                        {

                            (OBJ4.get(j)).name=name;

                            (OBJ4.get(j)).address=address;

                            (OBJ4.get(j)).phoneno=phoneno;

                            id2=(OBJ4.get(j)).id;

                            (OBJ4.get(j)).id=id;

                            (OBJ4.get(j)).empid=empid;

                            (OBJ4.get(j)).jodate=jodate;

                            (OBJ4.get(j)).depid=depid;

                            (OBJ4.get(j)).tstaff--;

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(depid.equals((OBJ1.get(j)).depid))

                        {

                            ((OBJ1.get(j)).templ).remove(id2);

                        }

                    }

                    break;

                }

                case 10:

                {

                    int j,k,l;

                    String s1=null,s2=null;

                    System.out.println("Enter the unique id of the staff and the department id where he is moved to");

                    String id1=br.readLine();

                    String depid=br.readLine();

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id1.equals((OBJ3.get(j)).id))

                        {

                            s1=((OBJ3.get(j)).depid);

                        }

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        if(depid.equals((OBJ4.get(j)).depid))

                        {

                            ((OBJ4.get(j)).tstaff)++;

                            s2=(OBJ4.get(j)).depid;

                        }

                        if(s1.equals((OBJ4.get(j)).depid))

                        {

                            ((OBJ4.get(j)).tstaff)--;

                        }

                    }

                    for(j=0;j<OBJ3.size();j++)

                    {

                        if(id1.equals((OBJ3.get(j)).id))

                        {

                            ((OBJ3.get(j)).depid)=s2;

                        }

                    }

                    for(j=0;j<OBJ1.size();j++)

                    {

                        if(s1.equals((OBJ1.get(j)).depid))

                        {

                            for(k=0;k<((OBJ1.get(j)).templ).size();k++)

                            {

                                if(id1.equals(((OBJ1.get(j)).templ).get(k)))

                                {

                                    ((OBJ1.get(j)).templ).remove(id1);

                                }

                            }

                        }

                        if(s2.equals((OBJ1.get(j)).depid))

                        {

                            for(l=0;l<((OBJ1.get(j)).templ).size();l++)

                            {

                                if(id1.equals(((OBJ1.get(j)).templ).get(l)))

                                {

                                    ((OBJ1.get(j)).templ).add(id1);

                                }

                            }

                        }

                    }

                    break;

                }

                case 11:

                {

                    int j,k=0;

                    double sum=0,avg=0;

                    for(j=0;j<OBJ3.size();j++)

                    {

                        k++;

                        sum=sum+(OBJ3.get(j)).salary;

                    }

                    for(j=0;j<OBJ4.size();j++)

                    {

                        k++;

                        sum=sum+(OBJ4.get(j)).salary;

                    }

                    avg=sum/k;

                    System.out.println("Average Salary of the employees in the bank:"+avg);

                    break;

                }

            }

            System.out.println("Enter 1 to continue and 100 to exit");

            z=Integer.parseInt(br.readLine());

        }

        while(z!=100);

    }

}

class Bank

{

    String name, branchid;

    ArrayList<String> tcust=new ArrayList<String>();

    ArrayList<String> tdepart=new ArrayList<String>();

    Bank(String name,String branchid)

    {

        this.name=name;

        this.branchid=branchid;

    }

}

class Department

{

    String depid;

    ArrayList<String> templ=new ArrayList<String>();

    Department(String depid)

    {

        this.depid=depid;

    }

}

class Person

{

    String name, address, phoneno, id;

    Person(String name,String address,String phoneno,String id)

    {

        this.name=name;

        this.address=address;

        this.phoneno=phoneno;

        this.id=id;

    }

}

class Customer extends Person

{

    String cusid,acno,tyacc,bal;

    Customer(String name,String address,String phoneno,String id,String cusid,String acno,String tyacc,String bal)

    {

        super(name,address,phoneno,id);

        this.cusid=cusid;

        this.acno=acno;

        this.tyacc=tyacc;

        this.bal=bal;

    }

}

class Employee extends Person

{

    String empid,jodate,depid;

    double salary;

    Employee(String name,String address,String phoneno,String id,String empid,String jodate,double salary,String depid)

    {

        super(name,address,phoneno,id);

        this.empid=empid;

        this.jodate=jodate;

        this.salary=salary;

        this.depid=depid;

    }

}

class Staff extends Employee

{

    String staid;

    Staff(String name,String address,String phoneno,String id,String empid,String jodate,double salary,String depid,String staid)

    {

        super(name,address,phoneno,id,empid,jodate,salary,depid);

        this.staid=staid;

    }

}

class Manager extends Employee

{

    String manid;

    int tstaff;

    Manager(String name,String address,String phoneno,String id,String empid,String jodate,double salary,String depid,String manid,int tstaff)

    {

         super(name,address,phoneno,id,empid,jodate,salary,depid);

         this.manid=manid;

         this.tstaff=tstaff;

    }

}
Person (Name, address, phone no, unique id) Customer (Customer id, account no, type of account, current balance) Employee (Employee id, Joining date, Salary, department id) Staff (Staff id) Manager (Manager id, number of staffs under the manager) Bank branch (Name, Branch Id, list of customers, list of departments) Department (department id, List of employees) Assume there is at most one manager in each department. Write a menu driven program to perform the following operations: 1. Add a bank branch. (You need to call this only once in the beginning) 2. Add a department. 3. Add a Customer/Employee/Staff/Manager in the database 4. Display information of a Customer/Employee/Staff/Manager 5. Display a department. 6. Delete a staff information (if staff is deleted then it should also be updated in the corresponding department.). 7. Delete a manager information. 8. Increase the salary of all employees (10% for staff and 20% for manager) who are working in a given department. 9. Assign a given existing staff to a given manager.. 10. Promoting a staff to a manager. 11. Change the department of a staff (if the department is changed then the staff is shifted automatically under the manager of the changed department if any) 12. Compute average salary of the employees in the bank in java  Person (Name, address, phone no, unique id)   Customer (Customer id, account no, type of account, current balance)   Employee (Employee id, Joining date, Salary, department id)    Staff (Staff id)   Manager (Manager id, number of staffs under the manager)    Bank branch (Name, Branch Id, list of customers, list of departments)      Department (department id, List of employees) Assume there is at most one manager in each department. Write a menu driven program to perform the following operations: 1.  Add a bank branch. (You need to call this only once in the beginning) 2.  Add a department. 3.   Add a Customer/Employee/Staff/Manager in the database 4.   Display information of a Customer/Employee/Staff/Manager 5.   Display a department. 6.   Delete a staff information (if staff is  deleted then it should also  be updated in the corresponding department.). 7.  Delete a  manager  information. 8.   Increase the salary of all employees (10% for staff and 20% for manager)  who are working in a given department. 9.   Assign a given existing staff to a given manager.. 10. Promoting a staff to a manager. 11. Change the department of a staff (if the department is  changed then the staff is shifted automatically under the manager of  the changed department if any) 12. Compute average salary of the employees in the bank    in java Reviewed by Unknown on 03:54 Rating: 5

No comments:

Powered by Blogger.