Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

18. The table below shows the normal boiling points of several substances Write

ID: 3640987 • Letter: 1

Question


18. 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 °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 (oC)
Water                             100
Mercury                           357
Copper                           1187
Silver                             2193
Gold                               2660


Your program should define and call a function inXperCent that takes
as parameters a reference value ref, a data value data, and a percent
age value x and returns 1 meaning true if data is within x % of ref-
that is, (ref - x% * ref) :5 data :5 (ref + x% * ref). Otherwis
inXperCent would return zero, meaning false. For example, the Call
inXperCent (357, 323, 10) would return true, since 10% of 357 is 35.7
and 323 falls between 321.3 and 392.7.

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
int inXperCent(double,double,double);
int main()
{int temp;
double percent;
cout<<"Enter a temperature: ";
cin>>temp;
cout<<"enter a percentage: ";
cin>>percent;
if(inXperCent(100,temp,percent)==1)
    cout<<"Your substance may be Water ";
else if(inXperCent(357,temp,percent)==1)
    cout<<"Your substance may be Mercury ";
else if(inXperCent(1187,temp,percent)==1)
    cout<<"Your substance may be Copper ";
else if(inXperCent(2193,temp,percent)==1)
    cout<<"Your substance may be Silver ";
else if(inXperCent(2660,temp,percent)==1)
    cout<<"Your substance may be Gold ";
else
    cout<<"Your substance is unknown ";
system("pause");
return 0;
}
int inXperCent(double ref ,double data,double percent)
{double p;
percent/=100.;
p=ref*percent;
if(ref+p>=data&&ref-p<=data)
    return 1;
else
    return 0;
}
           

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote