Sunday, 13 December 2015

Java Lab@home 7

1.Process shirt-related transactions for a Duke's Choice store. Compute the inventory level for a number of shirts. Then print out the shirt data sorted by description and by inventory count.

Ans CLICK HERE



2.Use the Deque object to match parentheses in a programming statement.


Ans CLICK HERE


3.• • Kiwi Inc. is a leading software development company in the US. The top management of the organization has found that the Help Desk division does not handle queries or issues of the employees on a priority basis. For this, the top management has decided to automate the tasks of the Help Desk division. Therefore, the management has assigned this task to the development team to create an application that has the following functionalities: Application must enable employees to log their requests or issues. Application must enable the team of the Help Desk division to handle queries on the first come first served basis. The development team has assigned the task to John, the Senior Software Developer. However, in the initial phase of development, John needs to create the user interface and create the application only for a single user. Help John to achieve the preceding requirements.

Ans  Ans

import java.until.ArrayDequr;

 public class Request  {

  ArrayDeque<String> pool;

  public Request()   {
       pool = new ArrayDeque<String>();
  }

  public void initRequest(String i, String p)   {
   String ID = i;
   String prb = p;

   String rqt = "Empliyee ID: " + ID +"\nProblem: " + prb;
   pool.add(rqt);

  }

  public void dispRequest()   {
   System.out.println
 ("================================================================");
  System.out.println("-----------------------REQUEST POOL-------\n");

  if (pool.isEmpty () == true) {
           System.out.println ("Currently, there is no request in the pool.");
        }
           else
        {
             for (String s : pool) {
             System.out.println (s);
             System.out.println
      ("--------------------------------------------");
    }
 }

}
      public void attdRequest () {
       String status;
 
     if (pool . isEmpty () == true) {
         System.out.println
   ("=====================================================");
     System.out.println ("Currently, there is no request in the pool.");
      } else {
           System.out.println
   ("=====================================================");
      System.out.println ("You need to resolve yhr following problem:");
        System.out.print(pool . getFirst () );
   
        status = "R";
 
      if (status . toUpperCase () . equals ("R") ) {
           System.out.println
    ("======================================================");
       System.out.println ("The problem has been resolved:");
         System.out.println (pool . getFirst () );
          pool . remove ();
     } else if (status . toUpperCase () . equals ("P") ) {
         System.out.println
   ("\n=======================================================");
         System.out.println ("Please resolve the problem ASAP .");
           } else {
              status = "N";
        }
    }
}
 
     public static void main (String [] args) {
        Request rq = new Request ();
        rq . initRequest ("3423", "System is not working");
        rq . initReuest (" 3764", "Internet is not working");
        rq . dispRequest ();
        rq . attdRequest ();
    }
}    

4.Write a program to store the student details, such as name and marks. In addition, you need to implement the functionality that helps in sorting the details according to name and marks, separately. For this, you need to implement two different logics. One will sort the details according to the name in ascending order, and the other will sort the details according to the marks in ascending order.

Ans Public class Student implements Comparable  {


  private String name;
  private int marks;

  public Student (String nm, int mk)  {
   this.name = nm;
   this.marks = mk;
  }

  public int getMarks()   {
   return marks;
  }

  public void getName()  {
   return name;
  }

  public void setName(String name)  {
   this.name = name;
  }

  public int compareTo (Object obj)  {
   Student s = (Student) obj;

   if (this.marks > s.getMarks())  {
        return 1;
   } else if (this.marks < s.getMarks())  {
        return -1;
   } Else {
        return 0;
   }
  }
  public String toString()  {
   StringBuffer buffer = new StringBuffer();
   buffer.append("Name: " + name + "\n");
   buffer.append("Marks: " + marks + "\n");
   return buffer.toString();
  }
 }


 import Java.until.Comparator;
 public class NameCompare implements Conparator{
  public int compare(Object a, Object b)
  {
   Student x = (Student) a;
   Student yx = (Student) b;
   return x.getName() .compareTo(y.getName());
  }
 }


  import java.until.ArrayList;
  import java.until.Collections;
  import java.until.ListIterator;

  public class Sorting  {

   public static void main (String[]  args)  {
    Student s1 = new Student("Joe",88);
    Student s2 = new Student("Bob",90);
    Student s1 = new Student("Alex",78);

    ArrayList<Student> obj = new ArrayList<>();
    obj.add(s1);
    obj.add(s2);
    obj.add(s3);

    System.out.println("Student details are:");

    ListIterator li = obj.listIterator();
    while (li.hasNext())   {
       System.out.println(li.next());
    }

    collection.sort(obj);
 
    System,out.println("Mark wise sort:");

    ListIterator li2 = obj.listIterator();
    while (li2.hasNext())
       System.out.println(li2.next());
    }
    Collection.sort(obj, new NameCompare());

    System.out.println("Name wise sort:");

    ListIterator li3 = obj.listIterator();
    while (li3.hasNext())  {
       System.out.println(li3.next());
   }
  }
 }

5.Write a program to store the details of football team players, such as name, age, number of matches played, ranking, and number of goals made. For this, you need to store the details of 15 players, which include goal-keeper and extras. In addition, you need to create three separate lists of 11 players for the triangular tournament. Moreover, you need to arrange players according to their ranking in the respective lists.

Ans    CLICK HERE




1 comment: