-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path5M_HsExtras.java
More file actions
42 lines (33 loc) · 966 Bytes
/
5M_HsExtras.java
File metadata and controls
42 lines (33 loc) · 966 Bytes
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
39
40
41
42
import java.util.Scanner;
public class HsExtras {
/*
Ingresar las horas trabajadas en una matriz de 15x6 posiciones
Calcular las horas extras realizadas por los trabajadores
Ingresarlas en una matriz de 15 posiciones
*/
public static void main (String[] args) {
int horas[][] = new int [5][6];
int hsExtras[] = new int [5];
Scanner teclado = new Scanner (System.in);
for (int f = 0; f < 5; f++) {
// Acumulador de las horas extras
int sumaHsExtras = 0;
for (int c = 0; c < 6; c++) {
System.out.print("\nIngrese la cantidad de horas trabajadas: ");
int tecla = teclado.nextInt();
horas[f][c] = tecla;
if (tecla > 160) {
sumaHsExtras = sumaHsExtras + (tecla - 160);
}
if (sumaHsExtras == 0) {
hsExtras[f] = 0;
} else {
hsExtras[f] = sumaHsExtras;
}
}
}
for (int f = 0; f < 5; f++) {
System.out.print("\nLa cantidad de horas extras trabajadas: " + hsExtras[f]);
}
}
}