Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
It’s the sale season again and Chef bought items worth a total of X rupees. The sale season offer is as follows:
Find the final amount Chef needs to pay for his shopping.
For each test case, output on a new line the final amount Chef needs to pay for his shopping.
Input: 4
15
70
250
1000
Output: 15
70
225
975
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.
#include <iostream>
using namespace std;
int main() {
// your code goes here
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;
}
# 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)
/* 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
{
// your code goes here
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);
}
}
}
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
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 >>