Java Programming
Answer 60a, 60b, 60c, 60d. Show code & output.

![60a. public class Demo { public static void main(String[] args) { ArrayList<Employee> al = new ArrayList<Employee>(); al.add(](http://img.homeworklib.com/questions/361c9930-0146-11eb-a87a-29bea7062071.png?x-oss-process=image/resize,w_560)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NOTE: WE MUST USE COMPARETO METHOD IN THE EMPLOYEE CLASS INORDER TO SORT ID
WE CAN ALSO USE LAMBDA FUNCTION BUT IT WORKS ONLY IN JAVA 8 OR ABOVE, HENCE I USED COMPARABLE AND COMPARATOR SEE THE OUTPUT BELOW
public class Employee implements Comparable<Employee>{
private int id;
private String name;
private int sal;
public Employee(int id, String name, int sal)
{
super();
this.id = id;
this.name = name;
this.sal = sal;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSal() {
return sal;
}
public void setSal(int sal) {
this.sal = sal;
}
@Override
public int compareTo(Employee o) {
return
this.getId()-o.getId();
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60 a.
USING COMPARABLE AND SORT
import java.util.*;
public class Demo{
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102,
"ram", 2000));
al.add(new Employee(103,
"shyam", 3000));
al.add(new Employee(101,
"sam", 10000));
al.add(new Employee(104,
"sameer", 40000));
Collections.sort(al);
for (Employee employee :
al) {
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}

USING COMPARATOR AND SORT
import java.util.*;
public class Demo {
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102, "ram",
2000));
al.add(new Employee(103, "shyam",
3000));
al.add(new Employee(101, "sam",
10000));
al.add(new Employee(104, "sameer",
40000));
al.sort(Comparator.comparing(Employee::getId));
for (Employee employee : al)
{
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60.b
WITH COMPARABLE AND SORT
import java.util.*;
public class Demo{
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102,
"ram", 2000));
al.add(new Employee(103,
"shyam", 3000));
al.add(new Employee(101,
"sam", 10000));
al.add(new Employee(104,
"sameer", 40000));
Comparator c =
Collections.reverseOrder();
Collections.sort(al,
c);
for (Employee employee :
al) {
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}

USING COMPARATOR AND SORT
import java.util.*;
public class Demo {
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102,
"ram", 2000));
al.add(new Employee(103,
"shyam", 3000));
al.add(new Employee(101,
"sam", 10000));
al.add(new Employee(104,
"sameer", 40000));
al.sort(Comparator.comparing(Employee::getId).reversed());
for (Employee employee :
al) {
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}
![2 4 Employee.java Demo.java X 1 import java.util.*; 3 public class Demo { 50 public static void main(String[] args) { 6 Array](http://img.homeworklib.com/questions/5c721ee0-0146-11eb-9830-b97bd0846131.png?x-oss-process=image/resize,w_560)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60.c
import java.util.*;
public class Demo {
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102,
"ram", 2000));
al.add(new Employee(103,
"shyam", 3000));
al.add(new Employee(101,
"sam", 10000));
al.add(new Employee(104,
"sameer", 40000));
al.sort(Comparator.comparing(Employee::getSal));
for (Employee employee :
al) {
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}
![Employee.java Demo.java X 1 import java.util.*; 3 public class Demo { 2 4 50 6 7 public static void main(String[] args) { Arr](http://img.homeworklib.com/questions/5cd81e50-0146-11eb-94f9-edbdb60a80d3.png?x-oss-process=image/resize,w_560)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60d.
import java.util.*;
public class Demo {
public static void main(String[] args) {
ArrayList<Employee> al = new
ArrayList<Employee>();
al.add(new Employee(102,
"ram", 2000));
al.add(new Employee(103,
"shyam", 3000));
al.add(new Employee(101,
"sam", 10000));
al.add(new Employee(104,
"sameer", 40000));
al.sort(Comparator.comparing(Employee::getSal).reversed());
for (Employee employee :
al) {
System.out.println(employee.getName());
System.out.println(employee.getId());
System.out.println(employee.getSal());
System.out.println("**************");
}
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
IF YOU HAVE ANY PROBLEM REGARDING THE SOLUTION PLEASE COMMENT BELOW I WILL HELP YOU
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Java Programming Answer 60a, 60b, 60c, 60d. Show code & output. public class Employee { private...
Java
Do 68a, 68b, 68c, 68d. Show code & output.
public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...
Java
Do 61a, 61b, 61c, 61d. Show Output and Code.
public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...
Java
Do 72a, 72b, 72c, 72d. Code & output required.
public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...
In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...
Fill in the find method and numMale method public class ComparableDemo { public void init(Object arr[]) { arr[0] = new Employee("Abby", 3000, 1, null, 'f'); arr[1] = new Employee("John", 2000, 2, (Employee)arr[0], 'm'); arr[2] = new Employee("Tim", 2000, 2, (Employee)arr[0], 'm'); arr[3] = new Employee("Tony", 1000, 3, (Employee)arr[0], 'm'); } //this method finds and returns the Employee object in the array whose name equals to //the...
What is the output of the code below? public class Hobbits { String name; public static void main(String [] args) { Hobbits [] h = new Hobbits[3]; int z = -1; while (z < 2) { z = z +1; h[z] = new Hobbits(); h[z].name = "bilbo"; if (z == 1) { h[z].name = "frodo"; } if (z == 2) { h[z].name = "sam"; } system.out.println(h[z].name + " is a "); system.out.println("good Hobbit name"); } } } Output: a. bilbo...
Java. What is the output of this code? Ace.java public class Ace { private double a; public Ace ( double x) { a = x; } public void multiply (double f) { a *= x; } public String toString () { return String.format ("%.3f", x); AceDem.java public class AceDemo { public static void main(String args[]) { Ace card = new Ace (2.133); card.multiply (.5); System.out.println (card); } }
in java coorect this code & screenshoot your output ---------------------------------------------------------------------- public class UNOGame { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); Scanner input2=new Scanner(System.in); UNOCard c=new UNOCard (); UNOCard D=new UNOCard (); Queue Q=new Queue(); listplayer ll=new listplayer(); System.out.println("Enter Players Name :\n Click STOP To Start Game.."); String Name = input.nextLine();...
I need code in java
The Student class:
CODE IN JAVA:
Student.java file:
public class Student {
private String name;
private double gpa;
private int idNumber;
public Student() {
this.name = "";
this.gpa = 0;
this.idNumber = 0;
}
public Student(String name, double gpa, int
idNumber) {
this.name = name;
this.gpa = gpa;
this.idNumber = idNumber;
}
public Student(Student s)...
I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String name, major, status; private int rank; public Student() { this.name = this.major = this.status = ""; this.rank = 0; } public Student(String name, String major, String status) { this.name = name; this.major = major; this.status = status; } public String getName() { return name; } public String getMajor() { return major; } public String getStatus() { return status; } public int...