The code to know the salary of a person who is paid overtime, after the 40th hour is paid as follows: ((paymentx hour * worked hours) + paymentxhora / 2 + paymentxhora) I mean that the employee after the 41st hour they pay as normal time plus half of a normal time, it does not work, no matter what the problem is, this is the code:
import java.util.Scanner;
class horasextras {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner entrada= new Scanner(System.in);
long horasTrabajadas;
long pagoxhora;
long salario;
System.out.print("Ingrese las horas trabajadas: ");
horasTrabajadas=entrada.nextLong();
System.out.print("Ingrese el pago por horas: ");
pagoxhora=entrada.nextLong();
if(horasTrabajadas<=40){
pagoxhora=pagoxhora;
}
else{
pagoxhora= (pagoxhora/2)+pagoxhora;
}
salario= horasTrabajadas*pagoxhora;
System.out.println("El salario es de: "+salario);
}
}
This reflects me on the console:
Enter the hours worked: 41
Enter the payment for hours: 10
Salary is: 425
It should be: 415