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.

27 changes: 27 additions & 0 deletions src/Elements.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Elements {
public static void main(String[] args) {
//Write a method in Java to find the
// smallest and second, smallest elements
// of a given array and print it in the
// console. Use loops and conditionals to
// develop the algorithm.

String[] elements = new String[4];
elements[0] = "3kg of Rice";
elements[1] = "20kg of Maize";
elements[2] = "25kg of Grains";
elements[3] = "5kg of Flour";

System.out.println("Elements of the Array:");
for (String element : elements) {System.out.println(element);}

for (int i = 0; i < 1; i++) {
System.out.println(elements[i] + " is the smallest element:");
}

for (int i = 3; i < 4; i++) {
System.out.println(elements[i] + " is the second smallest element: ");
}

}
}
85 changes: 85 additions & 0 deletions src/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//Create an Employee class to represent
// an employee of a company. Add all relevant
// properties and behaviors that you might need
// but, you have to include a salary property.
// Don't forget to add getters and setters.

public class Employee {
private String name;
private String department;
private String position;
private int salary;
private boolean workingEveryday;


public Employee (String name, String department, String position, int salary, boolean workingEveryday){
this.name = (name);
this.department = (department);
this.position = (position);
this.salary = (salary);
this.workingEveryday = (true);
}


public String getName() {
return name;
}

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

public String getDepartment(){
return department;
}

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

public String getPosition() {
return position;
}

public void setPosition(String position) {
this.position = position;
}

public int getSalary() {
return salary;
}

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

public boolean getWorkingEveryday() {
return workingEveryday;
}

public void setWorkingEveryday(boolean isWorkingEveryday) {
this.workingEveryday = true;
}

public void displayEmployeeInfo() {
System.out.println("Employee Details:");
System.out.println("Name: " + name);
System.out.println("Department: " + department);
System.out.println("Position: " + position);
System.out.println("Salary: $" + salary);
System.out.println("Works Everyday: " + true);
}

public void displayInternInfo() {
System.out.println("Employee Details:");
System.out.println("Name: " + name);
System.out.println("Department: " + department);
System.out.println("Position: " + position);
System.out.println("Salary: $" + salary);
System.out.println("Works Everyday: " + true);
}



}

33 changes: 33 additions & 0 deletions src/Integers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

public class Integers {
public static void main(String[] args) {

//Write a method in Java to get the difference
// between the largest and smallest values in an
// array of integers. The length of the array must
// be 1 and above. Use loops and conditionals to
// develop the algorithm.

int[] numberLists = {10, 20, 30, 40, 50, 60};
int highestNumber = numberLists[0];
for(int number : numberLists){
if(number > highestNumber){
highestNumber = number;
}
}
System.out.println("The Highest Number " + highestNumber);

int lowestNumber = numberLists[0];
for(int number : numberLists){
if(number == lowestNumber){
System.out.println("The Lowest Number " + lowestNumber);
}
}


int subtraction = highestNumber - lowestNumber;
System.out.println("The difference between Highest and Lowest Number is " + subtraction);

}
}

26 changes: 26 additions & 0 deletions src/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Intern extends Employee {

// Create an Intern class that extends
// from Employee. All the Interns have
// a salary limit of 20000 (constant).
// You must validate if an intern is
// created (or salary updated) with
// a bigger salary than the max.
// The max value is set.

public static final int MAX_SALARY = 20000;

public Intern(String name, String department, String position, int salary, boolean workingEveryday) {
super(name, department, position, Math.min(salary, MAX_SALARY), workingEveryday);
}

public void setSalary(int salary) {
if (salary > MAX_SALARY) {
System.out.println("Salary exceeded max intern limit of $" + MAX_SALARY);
} else {
super.setSalary(salary); // Call superclass method if valid
}
}


}
67 changes: 67 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
class Main {
public static void main(String[] args) {

Employee employee1 = new Employee("Noah", "Quality Assurance",
" Controller", 35000, true);
employee1.displayEmployeeInfo();

Employee employee2 = new Employee("Cole", "IT",
" Cloud Engineer", 20000, true);
employee2.displayEmployeeInfo();

Employee employee3 = new Employee("Tola", "Operations",
" Manager", 30000, true);
employee3.displayEmployeeInfo();

Employee employee4 = new Employee("Bukunmi", "Problem Solve",
" Associate", 22000, true);
employee4.displayEmployeeInfo();

Employee employee5 = new Employee("Funmilola", "Receiving",
" Associate", 28000, true);
employee5.displayEmployeeInfo();

Employee employee6 = new Employee("Bolanle", "Sorting",
" Sortation Associate", 14000, true);
employee6.displayEmployeeInfo();

Employee employee7 = new Employee("Bolajoko", "Recruitment",
" Recruitment Assistant", 11000, true);
employee7.displayEmployeeInfo();

Employee employee8 = new Employee("Abdul", "Delivery",
" Delivery Man", 8000, true);
employee8.displayEmployeeInfo();

Employee employee9 = new Employee("Abby", "Learning",
" Trainer", 36000, true);
employee9.displayEmployeeInfo();

Employee employee10 = new Employee("Adejare", "Instructing",
" Instructor", 8000, true);
employee10.displayEmployeeInfo();




// Interns child from Employee Parent Class

Intern intern1 = new Intern("Tolu", "HR", "HR Intern", 18000, true);
intern1.displayInternInfo();
intern1.setSalary(50000);

Intern intern2 = new Intern("Lovey", "Finance", "Finance Intern", 26000, true);
intern2.displayInternInfo();


Intern intern3 = new Intern("Lovey", "Finance", "Finance Intern", 25000, true);
intern3.displayInternInfo();





}


}