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.

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

public class Employee {
//Attributes
private String name;
private String surname;
private String birthday;
private String address;
private String email;
private String id;
private int socialSecurityNumber;
private String position;
private int level;
private double salary;

//Constructor
public Employee(String name, String surname, String birthday, String address, String email, String id, int socialSecurityNumber, String position, int level, double salary) {
this.name = name;
this.surname = surname;
this.birthday = birthday;
this.address = address;
this.email = email;
this.id = id;
this.socialSecurityNumber = socialSecurityNumber;
this.position = position;
this.level = level;
this.salary = salary;
}

//Getters
public String getName() {
return name;
}

public String getSurname() {
return surname;
}

public String getBirthday() {
return birthday;
}

public String getAddress() {
return address;
}

public String getEmail() {
return email;
}

public String getId() {
return id;
}

public int getSocialSecurityNumber() {
return socialSecurityNumber;
}

public String getPosition() {
return position;
}

public int getLevel() {
return level;
}

public double getSalary() {
return salary;
}

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

public void setSurname(String surname) {
this.surname = surname;
}

public void setBirthday(String birthday) {
this.birthday = birthday;
}

public void setAddress(String address) {
this.address = address;
}

public void setEmail(String email) {
this.email = email;
}

public void setId(String id) {
this.id = id;
}

public void setSocialSecurityNumber(int socialSecurityNumber) {
this.socialSecurityNumber = socialSecurityNumber;
}

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

public void setLevel(int level) {
this.level = level;
}

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

//Methods
public void information() {
System.out.println("======================================================" +
"\nThe Information for Employee " + name + " are the following:" +
"\n======================================================" +
"\nName: " + name +
"\nSurname: " + surname +
"\nBirthday: " + birthday +
"\nAddress: " + address +
"\nemail: " + email +
"\nID: " + id +
"\nSocialSecurityNumber: " + socialSecurityNumber +
"\nPosition: " + position +
"\nLevel: " + level +
"\nSalary: " + salary + " €" +
"\n======================================================");
}

public void setBonus(double bonus) {
this.salary = salary + bonus;
}
}
9 changes: 9 additions & 0 deletions src/Company/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Company;

public class Intern extends Employee {

//Constructor
public Intern(String name, String surname, String birthday, String address, String email, String id, int socialSecurityNumber, String position, int level, double salary) {
super(name, surname, birthday, address, email, id, socialSecurityNumber, position, level, salary);
}
}
120 changes: 120 additions & 0 deletions src/Company/Registration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package Company;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

//3. 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.

//4. 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.

//5. Write a program that creates 10 Employees and print it al the properties.

Scanner scanner = new Scanner(System.in);


System.out.println("""
------------------------------------------------------------------------------
If you want to do the calculation automatic answer: true
If you want to do the calculation manually answer: false""");


boolean autoCalc = scanner.nextBoolean();

if (!autoCalc) {
System.out.println("""
------------------------------------------------------------------------------
Enter the following information about the new Employee with the correct order:
Name, Surname, Birthday, Address, email, ID, Social Security Number, Position, Level, Salary""");

String name = scanner.nextLine();
String surname = scanner.nextLine();
String birthday = scanner.nextLine();
String address = scanner.nextLine();
String email = scanner.nextLine();
String id = scanner.nextLine();
int socialSecurityNumber = scanner.nextInt();
scanner.nextLine();
String position = scanner.nextLine();
int level = scanner.nextInt();
scanner.nextLine();
double salary = scanner.nextDouble();

System.out.println("""
------------------------------------------------------------------------------
Is this employee an intern?""");

boolean interntrue = scanner.nextBoolean();

Employee emp1;

do
if (interntrue && salary > 20000) {
System.out.println("""
------------------------------------------------------------------------------
All the Interns have a salary limit of 20000!
Please re-enter new amount""");
salary = scanner.nextDouble();

} while (interntrue && salary > 20000);


if (!interntrue) {
emp1 = new Employee(name, surname, birthday, address, email, id, socialSecurityNumber, position, level, salary);
} else {
emp1 = new Intern(name, surname, birthday, address, email, id, socialSecurityNumber, position, level, salary);
}

emp1.information();

if (interntrue && emp1.getSalary() == 20000) {
System.out.println("""
All the Interns have a salary limit of 20000, therefore this employee can not get a bonus !""");
System.exit(0);
}

System.out.println("""
----------------------------------------------------------------------
Enter the next bonus amount for the employer:""");

emp1.setBonus(scanner.nextDouble());

do
if (interntrue && emp1.getSalary() > 20000) {
System.out.println("""
------------------------------------------------------------------------------
All the Interns have a salary limit of 20000!
Please re-enter new bonus, so that the sum is not greater than 20000""");
emp1.setBonus(scanner.nextDouble());

} while (interntrue && emp1.getSalary() > 20000);


System.out.println("The Salary plus the bonus of " + name + " " + surname + "is: " + emp1.getSalary());
} else {

List<Employee> employees = new ArrayList<>();

employees.add(new Employee("Gustav", "Paloski", "19/07/1985", "Ravestreet 53", "guPalo@gmail.com", "GUPALO", 422525909, "Mechanical Engineer", 3, 3500));
employees.add(new Employee("Peri", "Mango", "17/07/1985", "Nordistreet 53", "perima@gmail.com", "PERIMA", 852156588, "Engineering Manager", 6, 10000));
employees.add(new Employee("Niko", "Toski", "19/08/1985", "Eleimonor 53", "nitokoski@gmail.com", "NISKIT", 136659586, "Electrical Engineer", 3, 3700));
employees.add(new Intern("Lary", "limou", "19/07/1989", "Mordika 53", "lalirimou@gmail.com", "lALIR", 789654357, "Automation Engineer", 4, 6000));
employees.add(new Employee("Helen", "Depathe", "12/02/1995", "Harilaou 53", "bepanthen85@gmail.com", "HEDEPA", 763124865, "Hand Worker", 1, 2000));
employees.add(new Employee("Susan", "Neifola", "06/03/1990", "Kaisie 53", "kimame@gmail.com", "SANFOLA", 958462352, "Mechanical Engineer", 3, 3500));
employees.add(new Intern("Dmitry", "Koronovitsch", "23/04/1975", "Senofarstreet 53", "nustazo@gmail.com", "DIKORO", 112156811, "Hand Worker", 2, 2300));
employees.add(new Employee("Giovani", "Garcia", "30/012/1998", "Bankisa 53", "denTheloAllopia@gmail.com", "GIGAVANI", 246885931, "Hand Worker", 1, 2000));
employees.add(new Intern("Linore", "Aloma", "01/04/1985", "Drakainas 53", "tola56@gmail.com", "LUCYPA", 455669852, "Hand Worker", 1, 2000));
employees.add(new Employee("Zak", "Meno", "14/01/1989", "Maindo 53", "paokararegate4@gmail.com", "MEZAK", 789654858, "Electrical Engineer", 3, 3700));

for (Employee employee : employees) {
employee.information();
}

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

import java.util.Arrays;
import java.util.Scanner;

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

//1. 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.

Scanner scanner = new Scanner(System.in);
//ArrayList<String> list = new ArrayList<String>();

System.out.println("-------------------------------------\n\n" +
"Enter the size of your preferred array please...");
int size = scanner.nextInt();
if (size < 2) {
System.out.println("Need at least 2 elements !\n" +
"Try again !");
System.exit(0); // cleanly terminates the program
}
int[] List = new int[size];

System.out.println("Enter one by one " + size + " integer numbers");
for (int i = 0; i < size; i++) {
List[i] = scanner.nextInt();
}

System.out.println("---Information about the List that you Created---\n" +
"-------------------------------------------------\n\n" +
"List: " + Arrays.toString(List));

int maxList = List[0];
int minList = List[0];
int doubleChecker = List[0];
int doubleCounter = 0;

for (int i = 0; i < size; i++) {
if (List[i] == List[0]) {
doubleCounter++;
}
if (maxList <= List[i]) {
maxList = List[i];
}
if (minList >= List[i]) {
minList = List[i];
}
}


int dif = maxList - minList;
System.out.println("1. The difference between the largest (" + maxList + ") and smallest (" + minList + ") values in your List is: " + dif);

//2. 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.

int[] List2 = new int[size - 1];
int step = 0;
int minList2 = 0;

if (doubleCounter == size) {
minList2 = minList;
} else {
for (int i = 0; i < size; i++) {
if (minList != List[i]) {
List2[step] = List[i];
step++;
}
}

minList2 = List2[0];

for (int i = 0; i < (size - 1); i++) {
if (minList2 >= List2[i]) {
minList2 = List2[i];
}
}
}
System.out.println("2a. Smallest Element: " + minList);
System.out.println("2b. Second Smallest Element: " + minList2);
}
}
Loading