Test Averages CodeChef Solution

Problem – Test Averages CodeChef Solution

Chef has scored A, B,A,B, and CC marks in 33 different subjects respectively.

Chef will fail if the average score of any two subjects is less than 3535. Determine whether Chef will pass or fail.

Input Format

  • First line will contain TT, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, three integers A, B, CA,B,C, denoting the Chef’s score in the three subjects.

Output Format

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 passPasspAss, and PASS will all be treated as identical).

Constraints

  • 1 \leq T \leq 10001≤T≤1000
  • 0 \leq A,B,C \leq 1000≤A,B,C≤100

Sample 1:

Input: 4
23 47 52
28 36 80
0 100 0
35 35 35
Output: 
Pass
Fail
Fail
Pass

Explanation:

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.549.5. Since all averages are greater than or equal to 3535, Chef will pass.

Test case 2: Since the average of the first two subjects is 3232 which is less than 3535, Chef will fail.

Test case 3: Since the average of the first and last subjects subjects is 00 which is less than 3535, Chef will fail.

Test case 4: Since the average of any two subjects is 3535 which is greater than or equal to 3535, Chef will pass.

Test Averages CodeChef Solution in C++14

#include <iostream>
using namespace std;

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    int k = a+b+c;
    if(k<105){
        cout<<"Fail\n";
        return;
    }
    else if(k-a <70){
        cout<<"Fail\n";
        return;
    }
    else if(k-c <70){
        cout<<"Fail\n";
        return;
    }
    else if(k-b <70){
        cout<<"Fail\n";
        return;
    }
    cout<<"Pass\n";
}
int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}

Test Averages CodeChef Solution in Python3

# cook your dish here
T=int(input())
for tc in range(T):
    (a,b,c)= map(float, input().split(' '))
    A1= ((a+b)/2)
    A2= ((c+b)/2)
    A3= ((a+c)/2)
    if (A1 >= 35.0) and (A2 >= 35.0) and (A3 >= 35.0) :
        print("pass")
    else:
        print("fail")

Test Averages 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
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int t =sc.nextInt();
		double m,n,l;
		while(t-- > 0)
		{
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    
		    m= (a+b)/2; n= (a+c)/2; l=(b+c)/2;
		    
		    if(m<35 || n<35 || l<35 )
		    {
		        System.out.println("Fail");
		    }
		    else
		    {
		        System.out.println("Pass");
		    }
		   
		      
		}
	}
}
Test Averages CodeChef Solution Review:

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

Find on CodeChef

Conclusion:

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 >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.