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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/src/Main.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
public class Employee {
private String name;
private String department;
private double salary;

public Employee() {
}

public Employee(String name, String department, double salary) {
this.name = name;
this.department = department;
this.salary = salary;
}

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 double getSalary() {
return salary;
}

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

@Override
public String toString() {
return "Employee{" +
"name='" + name + '\'' +
", department='" + department + '\'' +
", salary=" + salary +
'}';
}
}
21 changes: 21 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Main {
public static void main(String[] args) {
int[] array = {8, 12, 23, 31, 14};

int pequeño = Integer.MAX_VALUE;
int masPequeño = Integer.MAX_VALUE;

for (int i = 0; i < array.length; i++) {
if (array[i] < pequeño) {
masPequeño = pequeño;
pequeño = array[i];
} else if (array[i] < masPequeño && array[i] != pequeño) {
masPequeño = array[i];
}
}

System.out.println("El número más pequeño es: " + pequeño);
System.out.println("El segundo más pequeño es: " + masPequeño);
}
}

38 changes: 38 additions & 0 deletions Main2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Employee[] employees = new Employee[10];

for (int i = 0; i < 10; i++) {
System.out.println("Empleado #" + (i + 1));

System.out.print("¿Es un Intern? (true/false): ");
boolean isIntern = Boolean.parseBoolean(scanner.nextLine().trim());

System.out.print("Nombre: ");
String name = scanner.nextLine();

System.out.print("Departamento: ");
String department = scanner.nextLine();

System.out.print("Salario: ");
double salary = Double.parseDouble(scanner.nextLine());

if (isIntern) {
employees[i] = new intern(name, department, salary);
} else {
employees[i] = new Employee(name, department, salary);
}

System.out.println();
}

System.out.println("Lista de empleados:");
for (Employee emp : employees) {
System.out.println(emp);
}

scanner.close();
}
}
33 changes: 33 additions & 0 deletions intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class intern extends Employee {
public static final double MAX_SALARY = 20000.0;

public intern() {
}

public intern(String name, String department, double salary) {
super(name, department, salary);
if (salary > MAX_SALARY) {
System.out.println("El salario de un Intern no puede superar los " + MAX_SALARY + ". Se asignará el máximo permitido.");
super.setSalary(MAX_SALARY);
}
}

@Override
public void setSalary(double salary) {
if (salary > MAX_SALARY) {
System.out.println("El salario de un Intern no puede superar los " + MAX_SALARY + ". Se asignará el máximo permitido.");
super.setSalary(MAX_SALARY);
} else {
super.setSalary(salary);
}
}

@Override
public String toString() {
return "Intern{" +
"name='" + getName() + '\'' +
", department='" + getDepartment() + '\'' +
", salary=" + getSalary() +
'}';
}
}