diff --git a/Lab 1 Anthony Loustau/Lab 1 Anthony Loustau.iml b/Lab 1 Anthony Loustau/Lab 1 Anthony Loustau.iml new file mode 100644 index 0000000..9465dd8 --- /dev/null +++ b/Lab 1 Anthony Loustau/Lab 1 Anthony Loustau.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Employee.class b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Employee.class new file mode 100644 index 0000000..7d2ff45 Binary files /dev/null and b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Employee.class differ diff --git a/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Intern.class b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Intern.class new file mode 100644 index 0000000..317d557 Binary files /dev/null and b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/Intern.class differ diff --git a/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/createEmployee.class b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/createEmployee.class new file mode 100644 index 0000000..c2f12e5 Binary files /dev/null and b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/createEmployee.class differ diff --git a/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/differenceMaxMin.class b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/differenceMaxMin.class new file mode 100644 index 0000000..8d691a9 Binary files /dev/null and b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/differenceMaxMin.class differ diff --git a/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/smallestAndSecondSmallest.class b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/smallestAndSecondSmallest.class new file mode 100644 index 0000000..d51224f Binary files /dev/null and b/Lab 1 Anthony Loustau/out/production/Lab 1 Anthony Loustau/Lab1/smallestAndSecondSmallest.class differ diff --git a/Lab 1 Anthony Loustau/src/Lab1/Employee.java b/Lab 1 Anthony Loustau/src/Lab1/Employee.java new file mode 100644 index 0000000..aaa011b --- /dev/null +++ b/Lab 1 Anthony Loustau/src/Lab1/Employee.java @@ -0,0 +1,42 @@ +package Lab1; + +public class Employee { + private String name; + private int age; + private double salary; + + public Employee(String name, int age, double salary) { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + + public void printInfo() { + System.out.println("Name: " + name + ", Age: " + age + ", Salary: " + salary); + } +} diff --git a/Lab 1 Anthony Loustau/src/Lab1/Intern.java b/Lab 1 Anthony Loustau/src/Lab1/Intern.java new file mode 100644 index 0000000..4bb622e --- /dev/null +++ b/Lab 1 Anthony Loustau/src/Lab1/Intern.java @@ -0,0 +1,21 @@ +package Lab1; + +public class Intern extends Employee { + private static final double MAX_SALARY = 20000; + + public Intern(String name, int age, double salary) { + super(name, age, Math.min(salary, MAX_SALARY)); + if (salary > MAX_SALARY) { + System.out.println("Salary exceeds intern limit. Setting salary to " + MAX_SALARY); + } + } + + @Override + public void setSalary(double salary) { + if (salary > MAX_SALARY) { + System.out.println("Salary exceeds intern limit. Salary not updated."); + } else { + super.setSalary(salary); + } + } +} diff --git a/Lab 1 Anthony Loustau/src/Lab1/createEmployee.java b/Lab 1 Anthony Loustau/src/Lab1/createEmployee.java new file mode 100644 index 0000000..ea18f48 --- /dev/null +++ b/Lab 1 Anthony Loustau/src/Lab1/createEmployee.java @@ -0,0 +1,22 @@ +package Lab1; + +public class createEmployee { + public static void main(String[] args) { + Employee[] employees = new Employee[10]; + + employees[0] = new Employee("Alice", 30, 50000); + employees[1] = new Employee("Bob", 25, 45000); + employees[2] = new Intern("Charlie", 22, 21000); + employees[3] = new Employee("David", 35, 60000); + employees[4] = new Intern("Eve", 21, 18000); + employees[5] = new Employee("Frank", 28, 52000); + employees[6] = new Employee("Grace", 32, 48000); + employees[7] = new Intern("Hannah", 23, 20000); + employees[8] = new Employee("Ian", 40, 70000); + employees[9] = new Employee("Jane", 27, 46000); + + for (Employee emp : employees) { + emp.printInfo(); + } + } +} diff --git a/Lab 1 Anthony Loustau/src/Lab1/differenceMaxMin.java b/Lab 1 Anthony Loustau/src/Lab1/differenceMaxMin.java new file mode 100644 index 0000000..60f79cb --- /dev/null +++ b/Lab 1 Anthony Loustau/src/Lab1/differenceMaxMin.java @@ -0,0 +1,29 @@ +package Lab1; + +public class differenceMaxMin { + public static int differenceMaxMin(int[] arr) { + + int min = arr[0]; + int max = arr[0]; + + for (int i = 1; i < arr.length; i++) { + if (arr[i] < min) { + min = arr[i]; + } + if (arr[i] > max) { + max = arr[i]; + } + } + + return max - min; + } + + public static void main(String[] args) { + int[] numbers = {5, 10, 2, 8, 7}; + int diff = differenceMaxMin(numbers); + System.out.println("Difference between max and min: " + diff); + } +} + + + diff --git a/Lab 1 Anthony Loustau/src/Lab1/smallestAndSecondSmallest.java b/Lab 1 Anthony Loustau/src/Lab1/smallestAndSecondSmallest.java new file mode 100644 index 0000000..5e055a2 --- /dev/null +++ b/Lab 1 Anthony Loustau/src/Lab1/smallestAndSecondSmallest.java @@ -0,0 +1,32 @@ +package Lab1; + +public class smallestAndSecondSmallest { + public static void smallestAndSecondSmallest(int[] arr) { + int smallest = arr[0]; + int secondSmallest = arr[1]; + + if (secondSmallest < smallest) { + int temp = smallest; + smallest = secondSmallest; + secondSmallest = temp; + } + + for (int i = 2; i < arr.length; i++) { + if (arr[i] < smallest) { + secondSmallest = smallest; + smallest = arr[i]; + } else if (arr[i] < secondSmallest && arr[i] != smallest) { + secondSmallest = arr[i]; + } + } + + System.out.println("Smallest: " + smallest); + System.out.println("Second Smallest: " + secondSmallest); + } + + public static void main(String[] args) { + int[] numbers = {5, 10, 2, 8, 7}; + smallestAndSecondSmallest(numbers); + } +} +