Pages

Tuesday, January 4, 2011

Electricity bill

print "enter the value: "
consumed_units = gets.chomp.to_i
buffer_variable = consumed_units
if consumed_units > 0 and consumed_units <= 200
consumed_unit_cost = consumed_units * 1
consumed_units = 0
else
consumed_unit_cost = 200 * 1
consumed_units = consumed_units - 200
if (((consumed_units + 200) > 200) and  ((consumed_units + 200)<=350))
consumed_unit_cost = consumed_unit_cost + (consumed_units * 1.5)
consumed_units =0
end
end
if (((consumed_units + 200) > 350) and  ((consumed_units + 200)<=500))
consumed_unit_cost = consumed_unit_cost + (consumed_units * 2)
consumed_units =0
end
if (((consumed_units + 200) > 500) and  ((consumed_units + 200)<=750))
consumed_unit_cost = consumed_unit_cost + (consumed_units * 4)
consumed_units =0
end
if (((consumed_units + 200) > 750) and  ((consumed_units + 200)<=1000))
consumed_unit_cost = consumed_unit_cost + (consumed_units * 8)
consumed_units =0
end

puts buffer_variable

puts consumed_unit_cost

No comments:

Post a Comment