- import java.io.*;
- import java.util.*;
- import java.text.*;
- import java.math.*;
- import java.util.regex.*;
- public class Solution {
- public static void main(String[] args) {
- int id,cub;
- String dep,name;
- double sal;
- Scanner sc= new Scanner(System.in);
- Office o[]=new Office[5];
- for(int i=0;i<5;i++)
- {
- id=sc.nextInt();
- cub=sc.nextInt();
- dep=sc.nextLine();
- sc.next();
- o[i]=new Office(id, cub, dep);
- }
- Employee e[]=new Employee[5];
- for(int i=0;i<5;i++)
- {
- id=sc.nextInt();
- sc.nextLine();
- name=sc.nextLine();
- sal=sc.nextDouble();
- e[i] = new Employee(id, name, sal);
- }
- int c=sc.nextInt();
- Employee[] esort = sortEmployeeAsceName(e);
- for(int i=0;i<esort.length;i++)
- {
- System.out.println(esort[i].getEmployeeId()+" "+esort[i].getName());
- }
- Employee emp = employeeDetailsBasedOnCubicalNo(o,e,c);
- if(emp==null)
- System.out.println("No one sit on this cubical.");
- else
- System.out.println(emp.getEmployeeId()+" "+emp.getName()+" "+emp.getSalary());
- }
- public static Employee[] sortEmployeeAsceName(Employee e[])
- {
- Employee temp;
- for(int i=0;i<e.length-1;i++)
- {
- for(int j=i+1;j<e.length;j++)
- {
- if(e[i].getName().compareToIgnoreCase(e[j].getName())>0)
- {
- temp=e[i];
- e[i]=e[j];
- e[j]=temp;
- }
- }
- }
- return e;
- }
- public static Employee employeeDetailsBasedOnCubicalNo(Office o[], Employee[] e, int c)
- {
- int count=0;
- int p=0;
- for(int i=0;i<o.length;i++)
- {
- if(o[i].getCubicalNo()==c)
- {
- p=o[i].getEmployeeId();
- count=1;
- }
- }
- Employee temp=null;
- int l=0;
- for(int i=0;i<e.length;i++)
- {
- if(e[i].getEmployeeId()==p)
- {
- temp=e[i];
- }
- }
- if(count==0)
- {
- return null;
- }
- return temp;
- }
- }
- class Employee
- {
- public Employee(int employeeId, String name, double salary) {
- super();
- this.employeeId = employeeId;
- this.name = name;
- this.salary = salary;
- }
- public int getEmployeeId() {
- return employeeId;
- }
- public void setEmployeeId(int employeeId) {
- this.employeeId = employeeId;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public double getSalary() {
- return salary;
- }
- public void setSalary(double salary) {
- this.salary = salary;
- }
- private int employeeId;
- private String name;
- private double salary;
- }
- class Office
- {
- public Office(int employeeId, int cubicalNo, String department) {
- super();
- this.employeeId = employeeId;
- this.cubicalNo = cubicalNo;
- this.department = department;
- }
- public int getEmployeeId() {
- return employeeId;
- }
- public void setEmployeeId(int employeeId) {
- this.employeeId = employeeId;
- }
- public int getCubicalNo() {
- return cubicalNo;
- }
- public void setCubicalNo(int cubicalNo) {
- this.cubicalNo = cubicalNo;
- }
- public String getDepartment() {
- return department;
- }
- public void setDepartment(String department) {
- this.department = department;
- }
- private int employeeId;
- private int cubicalNo;
- private String department;
- }
[text] jcubical
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: