Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0755826

Browse files
Add files via upload
1 parent 0f32e74 commit 0755826

File tree

14 files changed

+279
-0
lines changed

14 files changed

+279
-0
lines changed

‎javadayday19/bin/Q2/Employee.class‎

1.71 KB
Binary file not shown.

‎javadayday19/bin/Q2/Main.class‎

1.48 KB
Binary file not shown.
1.95 KB
Binary file not shown.
1.49 KB
Binary file not shown.
834 Bytes
Binary file not shown.
869 Bytes
Binary file not shown.
848 Bytes
Binary file not shown.

‎javadayday19/src/Q2/Employee.java‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package Q2;
2+
3+
public class Employee implements Comparable<Employee>{
4+
5+
private int empId;
6+
7+
private String empName;
8+
9+
private double salary;
10+
11+
@Override
12+
public String toString() {
13+
return "Employee"+" ID"+empId+" "+"Name"+" "+empName+" "+"Salary"+" "+salary+" ";
14+
}
15+
16+
public Employee() {
17+
super();
18+
}
19+
20+
public Employee(int empId, String empName, double salary) {
21+
super();
22+
this.empId = empId;
23+
this.empName = empName;
24+
this.salary = salary;
25+
}
26+
27+
public int getEmpId() {
28+
return empId;
29+
}
30+
31+
public void setEmpId(int empId) {
32+
this.empId = empId;
33+
}
34+
35+
public String getEmpName() {
36+
return empName;
37+
}
38+
39+
public void setEmpName(String empName) {
40+
this.empName = empName;
41+
}
42+
43+
public double getSalary() {
44+
return salary;
45+
}
46+
47+
public void setSalary(double salary) {
48+
this.salary = salary;
49+
}
50+
51+
@Override
52+
public int compareTo(Employee o) {
53+
// TODO Auto-generated method stub
54+
return 0;
55+
}
56+
57+
58+
59+
}

‎javadayday19/src/Q2/Main.java‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package Q2;
2+
3+
import java.util.*;
4+
5+
public class Main {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
10+
Scanner sc = new Scanner(System.in);
11+
12+
TreeSet<Employee> ee = new TreeSet<>();
13+
14+
while(true) {
15+
16+
System.out.println("Enter Id Of Employee");
17+
18+
int eId= sc.nextInt();
19+
20+
System.out.println("Enter Name Of Employee");
21+
22+
String eName = sc.next();
23+
24+
System.out.println("Enter Salary of Employee");
25+
26+
double eSalary = sc.nextDouble();
27+
28+
29+
ee.add(new Employee(eId,eName,eSalary));
30+
31+
System.out.println("want to add another employee type Y for yes or type N for no");
32+
33+
String ss = sc.next();
34+
35+
if(ss.contains("N")) {
36+
37+
break;
38+
}
39+
}
40+
41+
System.out.println(ee);
42+
}
43+
44+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package javadayday19Q1;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.*;
6+
7+
8+
public class Main {
9+
10+
public static void main(String[] args) {
11+
12+
List<Product> prod = new ArrayList<>();
13+
14+
Scanner sc = new Scanner(System.in);
15+
16+
17+
while(true) {
18+
System.out.println("Please enter the product id");
19+
int pId = sc.nextInt();
20+
21+
System.out.println("Please enter the product name");
22+
String pName = sc.next();
23+
24+
System.out.println("Please enter the product price");
25+
double pPrice = sc.nextDouble();
26+
27+
28+
prod.add(new Product(pId,pName,pPrice));
29+
30+
31+
System.out.println("Want to add more products enter Y or enter N for no");
32+
33+
String ss = sc.next();
34+
35+
if(ss.contains("N")) {
36+
37+
break;
38+
39+
}
40+
}
41+
42+
System.out.println("Choose the option from 1 , 2, 3");
43+
44+
int choice = sc.nextInt();
45+
46+
if(choice == 1) {
47+
48+
Collections.sort(prod, new ProductSortByPrice());
49+
System.out.println(prod);
50+
}
51+
else if(choice == 2) {
52+
Collections.sort(prod, new ProductSortByName());
53+
System.out.println(prod);
54+
}
55+
else if(choice ==3) {
56+
Collections.sort(prod, new ProductSortByID());
57+
System.out.println(prod);
58+
}
59+
60+
}
61+
62+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /