Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/lab-java-basics.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions src/Employee/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package Employee;

public class Employee {
private String name;
private int ID;
private double salary;
private String department;

public Employee(String name, String department, double salary, int ID) {
this.name = name;
this.department = department;
this.salary = salary;
this.ID = ID;
}

public String getName() {
return name;
}

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

public int getID() {
return ID;
}

public void setID(int ID) {
this.ID = ID;
}

public double getSalary() {
return salary;
}

public void setSalary(double salary) {
this.salary = salary;
}

public String getDepartment() {
return department;
}

public void setDepartment(String department) {
this.department = department;
}

@Override
public String toString() {
return "Employee [Name = " + name + ", Department = " + department + ", Salary = " + salary + ", ID = " + ID + "]";
}
}



12 changes: 12 additions & 0 deletions src/Employee/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Employee;

public class Intern extends Employee{
private static final double MAX_SALARY = 20000.0;

public Intern(String name, String department, double salary, int ID) {
super(name, department, Math.min(salary, MAX_SALARY), ID);
if (salary > MAX_SALARY) {
System.out.println("Intern salary cant exceed " + MAX_SALARY + "setting to MAX");
}
}
}
22 changes: 22 additions & 0 deletions src/Employee/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package Employee;

public class Main {
public static void main(String[] args) {
Employee[] employees = new Employee[10];

employees[0] = new Employee("John", "IT", 50000, 67676);
employees[1] = new Employee("Chris", "CS", 30000, 12122);
employees[2] = new Employee("Amanda","HR",27000, 56789);
employees[3] = new Intern("Sukhwir", "BAR", 22500, 76343);
employees[4] = new Intern ("Ahmet", "CS,", 45000, 12345);
employees[5] = new Intern("Frank", "IT", 18000,56743 );
employees[6] = new Intern("Grace", "HR", 25000,67854 ); // salary capped at 20000
employees[7] = new Intern("Hank", "Finance", 20000,44544 );
employees[8] = new Employee("Ivy", "IT", 53000,54373 );
employees[9] = new Intern("Jack", "Marketing", 15000,33289 );

for(Employee e : employees){
System.out.println(e);
}
}
}
54 changes: 54 additions & 0 deletions src/Numbers/Numbers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package Numbers;

public class Numbers {
public static void main(String[] args) {
int[] arr = {5, 17, 3, 24, 71};

int difference = getDifference(arr);

System.out.println("Difference between highest and lowest number is " + difference);
findSmallestandSecondsmallest(arr);
}

public static int getDifference(int[] arr) {
int max = arr[0];
int min = arr[0];

for (int num: arr){
if (num > max){
max = num;
}
if(num < min){
min = num;
}
}
return max - min;
}



public static void findSmallestandSecondsmallest (int[] arr){
int smallest = arr[0];
int secondsmallest = arr[0];
for (int num : arr){
if (num < smallest) {
secondsmallest = smallest;
smallest = num;
}else if(num < secondsmallest && num != smallest) {
secondsmallest = num ;
}

}



System.out.println("Smallest : " +smallest+ " Second Smallest: " + secondsmallest);
}
}