Problem Description
" A certain grade of steel is graded according to the following conditions.
Hardness must be greater than 50.
Carbon content must be less than 0.7.
Tensile strength must be greater than 5600.
The grades are as follows:
Grade is 10 if all three conditions are met.
Grade is 9 if conditions (i) and (ii) are met.
Grade is 8 if conditions (ii) and (iii) are met.
Grade is 7 if conditions (i) and (iii) are met.
Grade is 6 if only one condition is met.
Grade is 5 if none of three conditions are met.
Write a program, if the user gives values of hardness, carbon content and tensile strength of the steel under consideration and display the grade of the steel.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three numbers hardness, carbon content and tensile strength of the steel.
Output
Print Grade of the steel depending on Conditions.
Constraints
1 <= T <= 1000
1<= hardness, carbon content, tensile strength <=10000
"CODING ARENA::
#include <stdio.h>
int main()
{
int i,n,a,c;
float b;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d\t%f\t%d",&a,&b,&c);
if(a>50 && b<0.7 && c>5600)
printf("\n10");
else if(a>50 && b<0.7 && c<5600)
printf("\n9");
else if(a<50 && b<0.7 && c>5600)
printf("\n8");
else if(a>50 && b>0.7 && c>5600)
printf("\n7");
else if(a>50 || b<0.7 || c>5600)
printf("\n6");
else
printf("\n5");
}
return 0;
}
Test Case 1
Input (stdin)3 53 0.6 5602 45 0 4500 0 0 0
Expected Output10 6 6
Test Case 2
Input (stdin)2 90 0.1 6000 4 8 40
Expected Output10 5
No comments:
Post a Comment