The table below shows the normal boiling points of several substances. Write a p
ID: 3626765 • 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 degrees Centigrade (C) 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.”Substance Normal Boiling Point (C)
Water 100
Mercury 357
Copper 1187
Silver 2193
Gold 2660
Explanation / Answer
#include #include #include using namespace std; int main(){ map m;//create a map of the table m["water"]=100; m["mercury"]=357; m["copper"]=1187; m["silver"]=2193; m["gold"]=2660; float boiling_point;//variable that takes in user's boiling point coutboiling_point; map::iterator iter=m.begin();//sets an interator to the beginning of the table float celsius;//needed to compare the user's input to the value in the table while(iter!=m.end()){//look through the entire table celsius=iter->second;//set it equal to the celsius value in the table if(boiling_point>=celsius*(0.95)&&boiling_pointRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.