The table below shows the normal boiling points of several substances. Write a p
ID: 3541920 • Letter: T
Question
The table below shows the normal boiling points of several substances. Write a program that prompts the user for the observed boiling point of a substance in Centigrade and identifies the substance if the observed boiling point is within 5% of the expected boiling point. If the data input is more than 5% higher or lower than any of the boiling points in the table, the program should output the message - SUBSTANCE UNKNOWN. The boiling point must be in the range from 90 to 3000 and input should be validated (use while loop). Program should continue until user opts to exit. Substance Normal boiling point (degrees Centigrade) Water 100 Mercury 357 Copper 1187 Silver 2193 Gold 2660 The table below shows the normal boiling points of several substances. Write a program that prompts the user for the observed boiling point of a substance in Centigrade and identifies the substance if the observed boiling point is within 5% of the expected boiling point. If the data input is more than 5% higher or lower than any of the boiling points in the table, the program should output the message - SUBSTANCE UNKNOWN. The boiling point must be in the range from 90 to 3000 and input should be validated (use while loop). Program should continue until user opts to exit. Substance Normal boiling point (degrees Centigrade) Water 100 Mercury 357 Copper 1187 Silver 2193 Gold 2660Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
double boiling_point;
string response="yes";
while(response.compare("yes")==0)
{
cout<<"Enter boiling point";
cin >> boiling_point;
cout << endl;
while(boiling_point<=90 || boiling_point>=3000)
{
cout <<"Invalid Boiling point entered. please enter valid one";
cin >> boiling_point;
cout << endl;
}
if(boiling_point>=95 && boiling_point<=105)
cout << "Substance is Water "<< endl;
else if(boiling_point>=339.15 && boiling_point<=374.85)
cout << "Substance is Mercury " <<endl;
else if(boiling_point>=1127.65 && boiling_point<=1246.35)
cout << "Substance is Copper " <<endl;
else if(boiling_point>=2083.35 && boiling_point<=2302.65)
cout << "Substance is Silver "<< endl;
else if(boiling_point>=2527 && boiling_point<=2793)
cout << "Substance is Gold " <<endl;
else
cout << "SUBSTANCE UNKNOWN " << endl;
cout <<"Do you want to continue (enter exit to stop)";
cin >> response;
cout << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.