Grade The Steel||codechef||beginner solution ||programming info

Grade The Steel

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.
  • Garde 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 hardnesscarbon content and tensile strength of the steel.

    Output

    For each test case, print Grade of the steel depending on Conditions, in a new line.

    Constraints

    •  T  1000
    • 0 hardness, carbon content, tensile strength  10000

    Example

    Input
    
    3 
    53 0.6 5602
    45 0 4500
    0 0 0 
    Output
    
    10
    6
    6
    SOLUTION USING C++ LANGUAGE:-
    #include <iostream> using namespace std; int main() { int t; cin >> t; while(t--) { int h,ts; double cc; cin>>h>>cc>>ts; if(h>50 && cc<0.7) { if(ts>5600) { cout <<10 <<endl; } else { cout <<9 <<endl; } } else if(cc<0.7 && ts>5600) { cout <<8 <<endl; } else if(h>50 && ts>5600) { cout <<7 <<endl; } else if(h>50 || cc<0.7 || ts>5600) { cout <<6 <<endl; } else { cout <<5 <<endl; } } // your code goes here return 0; }

    Share:

    No comments:

    Post a Comment

    Translate

    Recommended platforms

    1. codechef
    2. hackerrank
    3. codeforces
    4. leetcode
    5. hackerearth

    Popular Posts

    programming_info. Powered by Blogger.

    Blog Archive

    Recent Posts

    other platforms

    • geeks for geeks
    • w3schools
    • codepen
    • skillshare
    • udemy

    Pages

    reader support Support