-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrade_The_Steel.cpp
More file actions
56 lines (42 loc) · 1.54 KB
/
Grade_The_Steel.cpp
File metadata and controls
56 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Certain type of steel is graded according to the following conditions.
// Hardness of the steel must be greater than 50
// Carbon content of the steel must be less than 0.7
// Tensile strength must be greater than 5600
// The grades awarded are as follows:
// Grade is 10 if all three conditions are met
// Grade is 9 if conditions (1) and (2) are met
// Grade is 8 if conditions (2) and (3) are met
// Grade is 7 if conditions (1) and (3) are met
// Grade is 6 if only one condition is met
// Grade is 5 if none of the three conditions are met
#include <bits/stdc++.h>
int main () {
int T;
int hardness_grade = 50, tensile_grade = 5600;
float carbon_grade = 0.7;
std::cin >> T;
while (T--) {
int hardness, tensile_strength;
float carbon_content;
std::cin >> hardness
>> carbon_content
>> tensile_strength;
hardness = (hardness > hardness_grade) ? 1 : 0;
carbon_content = (carbon_content < carbon_grade) ? 1 : 0;
tensile_strength = (tensile_strength > tensile_grade) ? 1 : 0;
if (hardness || carbon_content || tensile_strength) {
if (hardness && carbon_content && tensile_strength)
std::cout << "10\n";
else if (hardness && carbon_content)
std::cout << "9\n";
else if (carbon_content && tensile_strength)
std::cout << "8\n";
else if (hardness && tensile_strength)
std::cout << "7\n";
else
std::cout << "6\n";
}
else
std::cout << "5\n";
}
}