logo image

Ruby program to calculate discount

Following program shows you how to calculate discount. In this program we get bill amount and discount from user and shows after discount amount using following formula Discount = bill - (bill * discount / 100)

puts "Enter bill amount:"
 bill = Integer(gets.chomp)
 puts "Enter discount percentage:"
 discount = Integer(gets.chomp)
 afterDiscount = bill - (bill * discount / 100)
 puts "After discount your bill is: #{afterDiscount}"


Enter bill amount:
Enter discount percentage:
After discount your bill is: 800