Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chef has scored A,B, and C marks in 3 different subjects respectively.
Chef will fail if the average score of any two subjects is less than 35. Determine whether Chef will pass or fail.
For each test case, if Chef will pass, print PASS
, otherwise print FAIL
.
You may print each character of the string in uppercase or lowercase (for example, the strings pass
, Pass
, pAss
, and PASS
will all be treated as identical).
Input: 4
23 47 52
28 36 80
0 100 0
35 35 35
Output: Pass
Fail
Fail
Pass
Test case 1: The average of the first two subjects is 35, the average of the first and last subject is 37.5, whereas the average of the last two subjects is 49.5. Since all averages are greater than or equal to 35, Chef will pass.
Test case 2: Since the average of the first two subjects is 32 which is less than 35, Chef will fail.
Test case 3: Since the average of the first and last subjects subjects is 0 which is less than 35, Chef will fail.
Test case 4: Since the average of any two subjects is 35 which is greater than or equal to 35, Chef will pass.
#include <iostream>
using namespace std;
int main() {
// your code goes here
int n;
cin>>n;
while(n--)
{
float a,b,c;
cin>>a>>b>>c;
float avg1=(a+b)/2;
float avg2=(b+c)/2;
float avg3=(a+c)/2;
if(avg1>=35 && avg2>=35 && avg3>=35)
cout<<"Pass"<<endl;
else
cout<<"Fail"<<endl;
}
return 0;
}
/* 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 sc= new Scanner(System.in);
int t= sc.nextInt();
while(t-->0){
int a= sc.nextInt();
int b= sc.nextInt();
int c= sc.nextInt();
float avg1=(float)(a+b)/2;
float avg2= (float)(a+c)/2;
float avg3= (float)(b+c)/2;
if (avg1<35 || avg2<35 || avg3<35)
System.out.println("Fail");
else
System.out.println("Pass");
}
}
}
T = int(input())
for i in range(T):
A,B,C = input().split(" ")
A = int(A)
B = int(B)
C = int(C)
if (A+B)/2 < 35 or (C+B)/2 < 35 or (A+C)/2 < 35:
print("FAIL")
else:
print("PASS")
In our experience, we suggest you solve this Test Averages 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 Test Averages CodeChef Solution
I hope this Test Averages 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 >>