304 North Cardinal St.
Dorchester Center, MA 02124

# Sale Season CodeChef Solution

## Problem – Sale Season CodeChef Solution

It’s the sale season again and Chef bought items worth a total of X rupees. The sale season offer is as follows:

• if X≤100, no discount.
• if 100<X≤1000, discount is 25 rupees.
• if 1000<X≤5000, discount is 100 rupees.
• if X>5000, discount is 500 rupees.

Find the final amount Chef needs to pay for his shopping.

### Input Format

• The first line of input will contain a single integer T, denoting the number of test cases.
• Each test case consists of single line of input containing an integer X.

### Output Format

For each test case, output on a new line the final amount Chef needs to pay for his shopping.

• 1≤T≤100
• 1≤X≤10000

### Sample 1:

``````Input: 4
15
70
250
1000
Output: 15
70
225
975``````

### Explanation:

Test case 1: Since X≤100, there is no discount.

Test case 3: Here, X=250. Since 100<250≤1000, discount is of 25 rupees. Therefore, Chef needs to pay 250−25=225 rupees.

## Sale Season CodeChef Solution in C++17

``````#include <iostream>
using namespace std;

int main() {
int t;
cin >> t;
while( t--){
int x;
cin >> x;
if(x<=100){
cout <<x<<endl;
}
else if(x <= 1000){
cout << x - 25<<endl;
}
else if(x <= 5000){
cout << x - 100<<endl;
}
else{
cout << x - 500<<endl;
}
}
return 0;
}
``````

## Sale Season CodeChef Solution in Pyth 3

``````# cook your dish here
t= int(input())
for i in range(t):
x = int(input())
if x<=100:
print(x)
elif x<=1000:
print(x-25)
elif x<=5000:
print(x-100)
else:
print(x-500)``````

## Sale Season CodeChef Solution in Java

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-- > 0)
{
int x = scan.nextInt();
int amt=x;
if(x>100 && x<=1000)
amt = x - 25;
else if(x > 1000 && x<= 5000)
amt = x - 100;
else if(x>5000)
amt = x - 500;
System.out.println(amt);
}
}
}
``````
##### Sale Season CodeChef Solution Review:

In our experience, we suggest you solve this Sale Season CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Sale Season CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this Sale Season CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions