Im not sure whats wrong with this.It is to ask for the substance bioling piont and tell what it is. Its not compiling. Any ideas?
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int withinXpercent(double ref,double data,double x) ;
double ref;
double data;
double x = .05;
{
cout<<"Enter the boiling point of the substance: "<<endl;
cout<<"% if",&data;
if (withinXpercent(100,data,x))
cout<<"Your substance is Water."<<endl;
else if ( withinXpercent(357,data,x))
cout<<"Your substance is Mercury."<<endl;
else if ( withinXpercent(1187,data,x))
cout<<"Your substance is Copper."<<endl;
else if ( withinXpercent(2193,data,x))
cout<<"Your substance is Silver."<<endl;
else if ( withinXpercent(2660,data,x))
cout<<"Your substance is Gold."<<endl;
else
cout<<"Substance Unknown."<<endl;
return 0;
}
int withinXpercent(double ref,double data,double x);
{
if (( ref - x * ref) <= data <= (ref + x * ref))
return 1;
else
return 0;
}
So i went through the link you posted and I used what they suggested and I dont know if im putting something wrong but does not work. This is the program so far:
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int withinXpercent(double ref,double data,double x);
double ref;
double data;
double x = .05;
cout<<"Enter the boiling point of the substance: "<<endl;
cout<<"% if",&data;
if (withinXpercent(100,data,x))
cout<<"Your substance is Water."<<endl;
else if ( withinXpercent(357,data,x))
cout<<"Your substance is Mercury."<<endl;
else if ( withinXpercent(1187,data,x))
cout<<"Your substance is Copper."<<endl;
else if ( withinXpercent(2193,data,x))
cout<<"Your substance is Silver."<<endl;
else if ( withinXpercent(2660,data,x))
cout<<"Your substance is Gold."<<endl;
else
cout<<"Substance Unknown."<<endl;
return 0;
}
int withinXpercent(double ref,double data,double x)
{
if (( ref - x * ref) <= data <= (ref + x * ref))
return 1;
else