# Ticket Fine Codechef Solution

Hello coders, today we are going to solve Ticket Fine Codechef Solution whose Problem Code is TCKTFINE.

As you already know that this site does not contain only the Codefchef solutions here, you can also find the solution for other programming problems. I.e. LeetcodeC programsC++ Programs SolutionsPython ProgramsWeb Technology, Data StructuresRDBMS Programs and Java Programs Solutions.

## Problem

On a certain train, Chef-the ticket collector, collects a fine of Rs. X if a passenger is travelling without a ticket. It is known that a passenger carries either a single ticket or no ticket.

PP passengers are travelling and they have a total of Q tickets. Help Chef calculate the total fine collected.

### Input Format

The first line contains a single integer T, the number of test cases. T lines follow. Each following line contains three integers separated by spaces, whose description follows.

• The first integer, X, is the fee in rupees.
• The second integer, P, is the number of passengers on the train.
• The third integer, Q, is the number of tickets Chef collected.

### Output Format

The output must consist of T lines.

• The ith line must contain a single integer, the total money(in rupees) collected by Chef corresponding to the ith test case.

• 1 ≤ T ≤ 10
1 ≤ X ≤ 10
• 0 ≤ QP ≤ 10

Input

```4
4 1 1
2 10 7
8 5 4
9 7 0```

Output

```0
6
8
63```

### Explanation:

Test case 1: The total number of passengers travelling without ticket are 1 – 1 = 0. So the total fine collected is 0⋅4=0 rupees.

Test case 2: The total number of passengers travelling without ticket are 10−7=3. So the total fine collected is 3⋅2=6 rupees.

Test case 3: The total number of passengers travelling without ticket are 5−4=1. So the total fine collected is 1⋅8=8 rupees.

Test case 4: The total number of passengers travelling without ticket are 7−0=7. So the total fine collected is 7⋅9=63 rupees.

### Ticket Fine Codechef Solution in CPP

```#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int n,a,b,c;
cin>>n;
while (n--)
{
cin>>a>>b>>c;
cout<<a*(b-c)<<endl;
}
return 0;
}
```

### Ticket Fine 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 s=new Scanner(System.in);
int n=s.nextInt();
for(int i=0;i<n;i++){
int x=s.nextInt();
int y=s.nextInt();
int z=s.nextInt();
if(y!=z){
System.out.println((y-z)*x);
}
else System.out.println("0");
}
}
}
```

### Ticket Fine Codechef Solution in Python

```# cook your dish here
t=int(input())
for i in range(t):
x,p,q=map(int,input().split())
z=p-q
a=x*z
print(a)
```

Disclaimer: The above Problem (Ticket Fine) is generated by CodeChef but the solution is provided by  Chase2learn.This tutorial is only for Educational and Learning purpose.

Finally, we are now, in the end, I just want to conclude some important message for you

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.