Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/07/2010, 05:17
elxus
 
Fecha de Ingreso: julio-2010
Ubicación: Zaragoza
Mensajes: 6
Antigüedad: 14 años, 6 meses
Puntos: 0
Desacuerdo Respuesta: Algoritmo para resolver

Cita:
Iniciado por pabloanm Ver Mensaje
Tengo el siguiente problema y me gustaría poder plantear un pseudocodigo sencillo para solucionarlo.

Una compañia de electricidad factura mensualmente a sus clientes de acuerdo con la siguiente tarifa: los primeros 500kw a 10 centavos el kw, los siguientes 500 kw a 18ctvos y pasados los 1000 kw a 24 ctavos. Debería poder calcular el monto a facturar teniendo como dato el consumo del cliente.

Desde ya, muchas gracias.
kw = kilowatios consumidos
total = centavos gastados
total2 = centavos sobrantes de 500 kw
total3 = centavos sobrantes de 1000 kw
total_definitivo = total definitivo
aux = kw sobrantes

if kw <= 500 then
total = kw * 10
end if
if kw > 500 and kw <= 1000 then
aux = kw - 500
total = 500 * 10
total2 = aux * 18
total_definitivo = total + total2
end if
if kw > 1000 then
aux = kw - 1000
total = 500 * 10
total2 = 500 * 18
total3 = aux * 24
total_definitivo = total + total2 + total3
end if