forked from ironhack-labs/lab-java-basics-es
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain2.java
More file actions
38 lines (29 loc) · 1.13 KB
/
Main2.java
File metadata and controls
38 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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();
}
}