Grade The Steel
Practice this coding question on Coding Gurukul.
Problem statement
A materials lab grades steel samples using three independent checks: hardness, carbon content and tensile strength. The grade depends on which checks pass, not on an average of the measurements. A technician enters several samples and needs the software to apply the published decision table consistently, including values exactly on a threshold. Your task The checks are H: hardness > 50, C: carbon content < 0.7, and T: tensile strength > 5600. Assign grade 10 if all three pass; 9 if only H and C pass; 8 if only C and T pass; 7 if only H and T pass; 6 if exactly one check passes; otherwise assign 5. Important details Every comparison is strict. Hardness 50, carbon 0.7 and strength 5600 each fail their respective check. Evaluate all three booleans before choosing the grade; the all-three case takes priority over a pair. Worked example A sample with hardness 60, carbon 0.5 and strength 6000 passes all three checks, so its grade is 10. A sample exactly at 50, 0.7 and 5600 receives 5.
Input format
First line: T. Next T lines: hardness carbonContent tensileStrength.
Output format
Print one integer grade per sample.
Constraints
1 <= T <= 1000; 0 <= hardness <= 1000; 0 <= carbonContent <= 2; 0 <= tensileStrength <= 100000; carbon has at most two decimal places.
Sample input
2 60 0.5 6000 50 0.7 5600
Sample output
10 5
Sign in to run or submit a solution in C++, Java or Python.