Dcoder icon

Total Expenses @ Dcoder

By Lochard | As a newbie programmer | 17 May 2023


Problem: Joey went for shopping. The shopkeeper gives a discount of 10% if the total expense exceeds 1000 .

Given total expense as input, write a program to calculate the total money Joey has to give to the shopkeeper after the discount, if discount is applicable.

Input: The first line contains an integer T, total number of test cases. The next T lines consist of an integer each representing total cost.

Output: Print the total money Joey has to pay after the discount. The precision must be upto 2 decimal places.

Constraints: 1 ≤ T ≤ 100

1 ≤ total_cost ≤ 100000

Sample Input: 2

900

1100

Sample Output: 

900.00

990.00

for t in range(int(input())):
  e = float(input())
  print("{0:.2f}".format(e * .9 if e > 1000 else e))

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.