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
11 changes: 11 additions & 0 deletions Lab 1 Anthony Loustau/Lab 1 Anthony Loustau.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions Lab 1 Anthony Loustau/src/Lab1/Employee.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
21 changes: 21 additions & 0 deletions Lab 1 Anthony Loustau/src/Lab1/Intern.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
22 changes: 22 additions & 0 deletions Lab 1 Anthony Loustau/src/Lab1/createEmployee.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
29 changes: 29 additions & 0 deletions Lab 1 Anthony Loustau/src/Lab1/differenceMaxMin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}



32 changes: 32 additions & 0 deletions Lab 1 Anthony Loustau/src/Lab1/smallestAndSecondSmallest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}