diff --git a/src/Intern.java b/src/Intern.java new file mode 100644 index 0000000..0ff9253 --- /dev/null +++ b/src/Intern.java @@ -0,0 +1,15 @@ +public class Intern extends employee { + private static final int maxSalaryForIntern = 20000; + + public Intern(int employeeId, String name, String surname, int age, String job, int salary) { + super(employeeId, name, surname, age, job, Math.min(salary, maxSalaryForIntern)); + if (salary > maxSalaryForIntern) { + System.out.println("Max salary for intern is 20000 EUR. Salary set to 20000 EUR."); + } + } +} + + + + + diff --git a/src/difflargesmall.java b/src/difflargesmall.java new file mode 100644 index 0000000..d7a4e2e --- /dev/null +++ b/src/difflargesmall.java @@ -0,0 +1,24 @@ +public class difflargesmall { + public static void main(String[] args) { + int[] numbers ={100,200,34,234,123,342}; + + int min = numbers[0]; + int max = numbers[0]; + + for (int i = 0; i < numbers.length; i++) { + if(numbers[i]>min){ + min=numbers[i]; + } + if (numbers[i]>max){ + max=numbers[i]; + } + } + + int diff =max-min; + + System.out.println("difference between the largest and smallest values:"+diff); + + + } + +} diff --git a/src/employee.java b/src/employee.java new file mode 100644 index 0000000..65179f1 --- /dev/null +++ b/src/employee.java @@ -0,0 +1,82 @@ +public class employee { + private int employeeid; + private String name; + private String surname; + private int age; + private String job; + private int salary; + + + public employee(int employeeid, String name, String surname, int age, String job, int salary) { + this.employeeid = employeeid; + this.name = name; + this.surname = surname; + this.age = age; + this.job = job; + this.salary = salary; + } + + public employee() { + } + + + public int getEmployeeid() { + return employeeid; + } + public void setEmployeeid(int employeeid) { + + this.employeeid = employeeid; + } + + + public String getName(){ + return name; + } + public void setName(String name){ + this.name =name; + } + + + public String surname(){ + return surname; + } + public void setsurname(String surname){ + this.surname =surname; + } + + + public int getAge() { + return age; + } + public void setAge(int age) { + this.age = age; + } + + + public String getjob() { + return job; + } + public void setJob() { + this.job=job; + } + + + public int getSalary() { + return salary; + } + public void setSalary(int salary) { + this.salary = salary; + } + + public void tenprint(){ + System.out.println("Employeeid:"+ employeeid); + System.out.println("Name:"+ name); + System.out.println("Surname:"+ surname); + System.out.println("Age:"+ age); + System.out.println("Job:"+ job); + System.out.println("salary:"+ salary); + } + + +} + diff --git a/src/smallsecondsmallest.java b/src/smallsecondsmallest.java new file mode 100644 index 0000000..debd77d --- /dev/null +++ b/src/smallsecondsmallest.java @@ -0,0 +1,21 @@ +public class smallsecondsmallest { + public static void main(String[] args) { + int[] numm ={100,200,34,234,123,342}; + int minn = numm[0]; + for (int i = 1; i < numm.length ; i++) { + if (numm[i] < minn) { + minn = numm[i]; + } + } + int secMin= Integer.MAX_VALUE; + for (int i = 0; i < numm.length; i++) { + if (numm[i]>secMin){ + secMin=numm[i]; + } + } + + System.out.println("smallest number:"+ minn); + System.out.println("second smallest number"+ secMin); + + } +} diff --git a/src/tenEmployees.java b/src/tenEmployees.java new file mode 100644 index 0000000..4961b62 --- /dev/null +++ b/src/tenEmployees.java @@ -0,0 +1,22 @@ +public class tenEmployees { + public static void main(String[] args) { + employee[] emp = new employee[10]; + + emp[0] = new employee(1, "John", "Smith", 30, "Software Developer", 30000); + emp[1] = new employee(1, "Emily", "Johnson", 32, "Software Engineer", 390000); + emp[2] = new employee(1, "Michael", "Brown", 36, "Senior Software developer", 60000); + emp[3] = new employee(1, "Sarah", "Williams", 31, "Fullstacks developer", 41000); + emp[4] = new employee(1, "David", "Jones", 25, "Lead Software Engineer", 60000); + emp[5] = new employee(1, "Olivia", "Taylor", 27, "Frontend-Developer", 33000); + emp[6] = new employee(1, "James", "Wilson", 22, "Backend-Developer", 38000); + emp[7] = new employee(1, "Emma", "Davis", 29, "Software Architect", 32000); + emp[8] = new employee(1, "Christopher", "Miller", 31, "Backend-Developer", 38000); + emp[9] = new employee(1, "Sophia", "Moore", 24, "Frontend-Developer", 32000); + + for (employee tenemp : emp) { + tenemp.tenprint(); + } + + } +} +