Answer to Question #174164 in C++ for Pradeepraj

Question #174164

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


1
Expert's answer
2021-03-22T10:31:46-0400
#include <iostream>
#include<string>
using std::cout;
using std::endl;
using std::cin;
using std::string;


string getstatus(string material) {
	if (material == "Water")
		return "Liquid";
	else if (material == "Gold" || material == "Ice")
		return "Solid";
	else if (material == "Oxygen")
		return "Gas";
	return "Unknown";
}


int main()
{
	string material;
	cout << "Enter the name of the material ";
	cin >> material;
	cout << "Physical state of the material " << getstatus(material);


	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS