The table given below shows the list of gases, liquids and solids. By entering the substances, find the state of the material. Implement the above logic through C++.
S.No.
Materials
1
Water
2
Oxygen
3
Gold
4
Ice
5
Petrol
#include <bits/stdc++.h>
using namespace std;
int main() {
int material;
cout<<"Enter the name of material: "<<endl;
cout<<"For Water: enter 1"<<endl;
cout<<"For Oxyen: enter 2"<<endl;
cout<<"For Gold: enter 3"<<endl;
cout<<"For Ice: enter 4"<<endl;
cout<<"For Patrol: enter 5"<<endl;
cin>>material;
switch(material){
case 1:
cout<<"You have selected Water."<<endl;
cout<<"It is liquid NTP."<<endl;
break;
case 2:
cout<<"You have selected Oxygen."<<endl;
cout<<"It is gas at NTP."<<endl;
break;
case 3:
cout<<"You have selected Gold."<<endl;
cout<<"It is Solid at NTP."<<endl;
break;
case 4:
cout<<"You have selected Ice."<<endl;
cout<<"It is Solid at NTP."<<endl;
break;
case 5:
cout<<"You have selected Patrol."<<endl;
cout<<"It is liquid at NTP."<<endl;
break;
default:
cout<<"You have choosen incorrect value, please choose correct one"<<endl;
break;
}
return 0;
}
Comments
Leave a comment