I have a problem with this exercise. (Attachment enunciated)
The owner of a parking lot requires a program that allows him to determine how much you should charge for the use of parking for your customers. The rates that are had are the following: The first two hours at $ 5.00 each. The next three at $ 4.00 each. The next five at $ 3.00 each. After ten hours the cost for each one is two dollars. Read customer data and parking hours. Present the respective output.
I have evaluated the first condition very well but in the others I have a problem. When I compile and I put him that I need 5 hours of parking he throws me a total of 18 dollars, it is assumed that 5 is included in the second conditional and I must leave 14 as I have put it. The other problem is similar, in the third conditional I need 9 hours of parking and I get 34 when I should leave 17. I hope you can help me, I attach the code.
package estacionamiento;
import java.util.Scanner;
public class Estacionamiento {
public static void main(String[] args) {
//Declaración de variables tipo cadena, enteras y flotantes//
String nombrecliente, ced;
int horas;
double cobroestacionamiento=0;
//Ingreso de los Datos//
Scanner entrada=new Scanner(System.in);
System.out.println("Digite un nombre y apellido: ");
nombrecliente=entrada.nextLine();
System.out.println("Ingrese CI: ");
ced=entrada.nextLine();
System.out.print("¿Por cuantas horas usará el estacionamiento?: ");
horas = entrada.nextInt();
//CALCULO CONDICIONAL//
if(horas<=2)
cobroestacionamiento=horas*5.00;
if(horas>2&&horas<=5)
cobroestacionamiento=2*5+(horas-3)*4.00;
if(horas>5&&horas<=10)
cobroestacionamiento=2*5+3*4+(horas-5)*3.00;
if(horas>10)
cobroestacionamiento=2*5+3*4+3*5+(horas-10)*2.00;
System.out.println("---------DATOS DEL CLIENTE---------");
System.out.println("Nombres_Cliente:" +nombrecliente);
System.out.println("Cedula_Cliente:" +ced);
System.out.println("Sus horas de parqueo son: " +horas+' '+"horas");
System.out.println("Total a pagar: " +cobroestacionamiento+' '+"dolares");
}
}