Java
Do 68a, 68b, 68c, 68d. Show code & output.

![68a. public class Demo { public static void main(String[] args) { ArrayList<Employee> al = new ArrayList<Employee>(); al.add(](http://img.homeworklib.com/questions/dabf5bd0-0219-11eb-8894-3184090418b6.png?x-oss-process=image/resize,w_560)
68a.
![40 41 42 43 44 45 46 47 48 class Demo public static void main(String[] args) { //680 ArrayList<Employee> al = new ArrayList<E](http://img.homeworklib.com/questions/db682f50-0219-11eb-b13e-29e56a535ac1.png?x-oss-process=image/resize,w_560)
Sample Output :
![Run: Demo X → If 1 C:\Program Files\Java\jdk-13\bin\java.exe [101, 102, 103, 104, 105, 106] (sam, sameer, shyam, ram, rames](http://img.homeworklib.com/questions/dbd87810-0219-11eb-a40b-d3242643a2ce.png?x-oss-process=image/resize,w_560)
Program Code to Copy
import java.util.ArrayList; import java.util.HashSet; import java.util.stream.Collectors;
class Demo{
public static void main(String[] args) {
//68a
ArrayList<Employee> al = new ArrayList<Employee>();
al.add(new Employee(101,"sam",1000));
al.add(new Employee(102,"sameer",2000));
al.add(new Employee(103,"shyam",3000));
al.add(new Employee(104,"ram",4000));
al.add(new Employee(105,"ramesh",5000));
al.add(new Employee(106,"sameera",60000));
ArrayList<Integer> ids = new ArrayList(al.stream().map(x->x.getId()).collect(Collectors.toList()));
ArrayList<String> names = new ArrayList(al.stream().map(x->x.getName()).collect(Collectors.toList()));
ArrayList<Integer> sals = new ArrayList(al.stream().map(x->x.getSal()).collect(Collectors.toList()));
System.out.println(ids);
System.out.println(names);
System.out.println(sals);
}
}
68b
Program Code Screenshot
![40 41 42 43 44 45 46 class Demo{ public static void main(String[] args) { //680 ArrayList<Employee> al = new ArrayList<Employ](http://img.homeworklib.com/questions/dc5e8860-0219-11eb-aad7-2581a6a5218d.png?x-oss-process=image/resize,w_560)
Sample Output :

Program Code to Copy
import java.util.ArrayList; import java.util.HashSet; import java.util.stream.Collectors;
class Demo{
public static void main(String[] args) {
//68a
ArrayList<Employee> al = new ArrayList<Employee>();
al.add(new Employee(101,"sam",10000));
al.add(new Employee(102,"sameer",2000));
al.add(new Employee(103,"shyam",30000));
al.add(new Employee(104,"ram",4000));
al.add(new Employee(105,"ramesh",15000));
al.add(new Employee(106,"sameera",60000));
ArrayList<Employee> highSal = new ArrayList(al.stream().filter(x->x.getSal()>5000).collect(Collectors.toList()));
System.out.println(highSal);
}
}
68c.
Program Code Screenshot :
![Main.java import java.util. HashSet; 1 2 3 4 5 on 7 class Demo{ public static void main(String[] args) { // Create hash set H](http://img.homeworklib.com/questions/dd2158e0-0219-11eb-91a4-4fd0b34f0258.png?x-oss-process=image/resize,w_560)
Sample Output :
![Run: Demo X C:\Program Files\Java\jdk-13\bin\java.exe Integers [3, 4, 5] IR Process finished with exit code o](http://img.homeworklib.com/questions/dd7e1e80-0219-11eb-8ce7-9f928c61c6c4.png?x-oss-process=image/resize,w_560)
Program Code to Copy
import java.util.HashSet;
class Demo{
public static void main(String[] args) {
//Create hash set
HashSet<Integer> ints = new HashSet<>();
//Add ints
ints.add(4);
ints.add(3);
ints.add(4);
ints.add(5);
System.out.println("Integers "+ints);
}
}
68d.


Sample Output :

Program Code to Copy
import java.util.HashSet;
import java.util.Objects;
class Employee{
private int id;
private String name;
private int sal;
public Employee(int id, String name, int sal) {
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 boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Employee employee = (Employee) o;
return id == employee.id &&
sal == employee.sal &&
Objects.equals(name, employee.name);
}
//Hashcode and equals method
@Override
public int hashCode() {
return Objects.hash(id, name, sal);
}
@Override
public String toString() {
return "Employee{" +
"id=" + id +
", name='" + name + '\'' +
", sal=" + sal +
'}';
}
}
class Demo{
public static void main(String[] args) {
//68a
HashSet<Employee> al = new HashSet<>();
al.add(new Employee(101,"sam",10000));
al.add(new Employee(101,"sam",10000));
al.add(new Employee(103,"shyam",30000));
al.add(new Employee(104,"ram",4000));
al.add(new Employee(103,"shyam",30000));
al.add(new Employee(106,"sameera",60000));
System.out.println(al);
}
}Java Do 68a, 68b, 68c, 68d. Show code & output. public class Employee { private int...
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 Programming
Answer 60a, 60b, 60c, 60d. 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...
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;...
Given: public class ItemTest { private final int id; public ItemTest(int id) { this.id = id; } public void updateId(int newId) { id = newId; } public static void main(String[] args) { ItemTest fa = new ItemTest(42); fa.updateId(69); System.out.println(fa.id); } } What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The attribute id in the ItemTest object remains unchanged. D. The attribute id in the ItemTest object is modified to the new value. E....
Debugging exercise Programmer Began programming the following program, but made some mistakes. Please debug: class Student{ private int id; private String name; private String city; Student(String name, String city){ this.name = name; this.city = city; } Student(int id, String place){ this.id = id; this.place =name; } void Student(int id, String name, String city){ this.id = id; this.name = name; this.city =...
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...
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...
What is the final value of the count field? public class Person { private String name; private int age; private static int count=0; public Person(String name, int age) { this.name = name; this.age age; count++; } public static void main(String[] args) { Person a - new Person("John Doe". 35): Person b new Person("Jane Doe", 38): for(int i=0;i<5;i++) Person tempa
I need help displaying two zeroes in hours:minutes:seconds. In
Java.
I need some help for the time to display correctly. I want it to
display double zeroes. 06:00:00 and 12:00:00.
public class Clock {
String name;
static int uid=100;
int id;
int hr;
int min;
int sec;
public Clock() {
this.name="Default";
this.id=uid;
this.hr=00;
this.min=00;
this.sec=00;
uid++;
}
public Clock(String name, int hr, int min, int sec) {
if (hr<=24 && min <=60 && sec <=60)
{
this.hr = hr;
this.min...
JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...