Pass the Exam Solution Codechef
Chef appeared for an exam consisting of 3 sections. Each section is worth 100 marks. Chef scored A marks in Section 1, B marks in section 2, and C marks in section 3. Chef passes the exam if both of the following conditions satisfy:
- Total score of Chef is ≥100;
- Score of each section ≥10.
Determine whether Chef passes the exam or not.
Input Format
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of a single line containing 3 space-separated numbers A,B,C – Chef’s score in each of the sections.
Output Format
- For each test case, output PASS if Chef passes the exam, FAIL otherwise.
- Note that the output is case-insensitive i.e. PASS, Pass, pAsS, and pass are all considered same.
Constraints
- 1≤T≤1000
- 0≤A,B,C≤100
Sample Input 1
5
9 100 100
30 40 50
30 20 40
0 98 8
90 80 80
Sample Output 1
FAIL
PASS
FAIL
FAIL
PASS
Explanation
- Test Case 1: Although Chef’s total score is 209≥100, still Chef fails the exam since his score in section 11 is <10.
- Test Case 2: Chef cleared each section’s cutoff as well his total score =120≥100.
- Test Case 3: Although Chef cleared each section’s cutoff but his total score is 90<100. So he fails the exam.
- Test Case 4: Although Chef’s total score is 106≥100, still Chef fails the exam since his score in section 11 is <10.
- Test Case 5: Chef cleared each section’s cutoff as well his total score =250≥100.
SOLUTION
Program: Pass the Exam Solution in Python
for _ in range(int(input())):
l=list(map(int,input().split()))
if l[0]>=10 and l[1]>=10 and l[2]>=10 and sum(l)>=100:
print('Pass')
else:
print('Fail')
Program: Pass the Exam Solution in C++
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
if(a>=10 && b>=10 && c>=10)
{
if(a+b+c>=100)
{
cout<<"PASS"<<endl;
}
else
{
cout<<"FAIL"<<endl;
}
}
else
{
cout<<"FAIL"<<endl;
}
}
return 0;
}
Program: Pass the Exam Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan = new Scanner(System.in);
int test = scan.nextInt();
while(test!=0){
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
if(a>=10 && b>= 10 && c>=10 && (a+b+c)>= 100)
System.out.println("PASS");
else
System.out.println("FAIL");
test--;
}
}
}
Related: