In: Computer Science
A discount store is having a sale where everything is 15% off. Write a program to display a table showing the original price and the discounted price. This program requires no input and your table should include headings and the original prices should go from 99 cents to $9.99 in increments of 50 cents.
Python
Python code:
#printing the headers
print("Original price{:>10} Discounted price{:<15}".format("
"," "))
#initializing i as 0.99
i=0.99
#looping till i is 9.99
while(i<=9.99):
#printing Original and Discounted price
print("${:.2f}{:>20}${:.2f}{:<15}".format(i," ",i-i*0.15,"
"))
#incrementing i with 0.5
i+=0.5
Screenshot:
Output: