Hello Programmers In this post, you will know how to solve the Total Expenses CodeChef Solution. The Problem Codes is FLOW009.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.
Problem
While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000.
If the quantity and price per item are input, write a program to calculate the total expenses.
Input
The first line contains an integer T, total number of test cases. Then follow T lines, each line contains integers quantity and price.
Output
For each test case, output the total expenses while purchasing items, in a new line.
Constraints
- 1 <= T <= 1000
- 1 <= quantity, price <= 100000
Example
Input
3 100 120 10 20 1200 20
Output
12000.000000 200.000000 21600.000000
Total Expenses CodeChef Solution in Python
for i in range(int(input())): total = 0 m, n = map(int, input().split()) total += (m * n) if m > 1000: discount = total - (total * 10/100) print(discount) else: print(total)
Total Expenses CodeChef Solutions in CPP
#include <iostream> using namespace std; int main() { // your code goes here int t; double e,f,p,d; cin>>t; while(t--){ cin>>e>>f; p = e*f; if(e>1000){ d=p/10; p-=d; printf("%f\n",p); } else{ printf("%f\n",p); } } return 0; }
Total Expenses CodeChef Solutions in JAVA
import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int TEST = sc.nextInt(); while(TEST-->0) { int a=sc.nextInt(); int b=sc.nextInt(); float dis=a*b; if(a>1000) { dis=dis-(dis/10); System.out.println(dis); } else { System.out.println(dis); } } } }
Disclaimer: The above Problem (Total Expenses) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.
Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.
Next: Primality Test Codechef Solution