Write a program to display the grade of the steel, based on the values of hardness, carbon content and tensile strength of the steel, given by the user.

 

A certain type of steel is graded according to the following conditions.
  1. Hardness of the steel must be greater than 50
  1. Carbon content of the steel must be less than 0.7
  1. 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
Write a program to display the grade of the steel, based on the values of hardness, carbon content and tensile strength of the steel, given by the user.






OURSHOPKEEPER






3 
53 0.6 5602
45 0 4500
0 0 0


#include <iostream>
using namespace std;
int main()
{
    int htT;
    float c;
    cin >> T;
    while (T--)
    {
        cin >> h;
        cin >> c;
        cin >> t;
        if (h > 50 && c < 0.7 && t > 5600)
        {
            cout << "10"<<endl;
        }

        else if (h > 50 && c < 0.7)
        {
            cout << "9"<<endl;
        }
        else if (c < 0.7 && t > 5600)
        {
            cout << "8"<<endl;
        }
        else if (h > 50 && t > 5600)
        {
            cout << "7"<<endl;
        }
        else if (h > 50 || c < 0.7 || t > 5600)
        {
            cout << "6"<<endl;
        }
        else
        {
            cout << "5"<<endl;
        }
    }
    return 0;
}






    


Click on the above button to download the code.



Post a Comment

If you have furthur QUERIES please let us know

Previous Post Next Post