-
Lenguaje
Java usando Scanner
-
Descripción
A un trabajador le pagan según sus horas trabajadas y las horas extras. Si la cantidad de horas trabajadas es mayor a 54 horas quiere decir que trabajó horas extras, las horas extras incrementan en un 50% de la hora normal. Calcular el salario del trabajador dadas horas trabajadas y el valor por hora.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;
public class SalarioDeUnTrabajador {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double horas_trabajadas, pago_por_hora, salario_del_trabajador;
System.out.print("Ingresa el valor de horas trabajadas: ");
horas_trabajadas = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de pago por hora: ");
pago_por_hora = in.nextDouble();
in.nextLine();
salario_del_trabajador=horas_trabajadas*pago_por_hora;
if(horas_trabajadas>54)
salario_del_trabajador=salario_del_trabajador+(horas_trabajadas-54)*pago_por_hora*0.5;
System.out.println("Valor de salario del trabajador: " + salario_del_trabajador);
}
}
public class SalarioDeUnTrabajador {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double horas_trabajadas, pago_por_hora, salario_del_trabajador;
System.out.print("Ingresa el valor de horas trabajadas: ");
horas_trabajadas = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de pago por hora: ");
pago_por_hora = in.nextDouble();
in.nextLine();
salario_del_trabajador=horas_trabajadas*pago_por_hora;
if(horas_trabajadas>54)
salario_del_trabajador=salario_del_trabajador+(horas_trabajadas-54)*pago_por_hora*0.5;
System.out.println("Valor de salario del trabajador: " + salario_del_trabajador);
}
}