okay..thanks...duh.
one last question...
here's the new prototype & fuction,
why am I not getting a yes or no when i call the bool function?
actually what the hey..here's the entire thing...my output is a little messed up...
Code:
#include<iostream>
#include<iomanip>
#include<fstream>
#include<cmath>
#include<string>
using namespace std;
bool isatriangle (double, double, double);
double semiperimeter ( double, double, double );
double perimeter ( double, double, double );
double area ( double, double, double );
int main()
{
double s1, s2, s3;
ifstream infile("A:\\IF1.txt");
if(!infile){
cerr << "Cannot open input file" << endl;
return 1;
}
ofstream outfile("A:\\0F1.txt");
if(!outfile){
cerr << "Cannot open output file" << endl;
return 1;
}
cout << setprecision(3);
cout << setiosflags(ios::fixed | ios::showpoint);
cout << "\n" << endl;
bool Flag = true;
while(infile >> s1 >> s2 >> s3){
if(Flag==true){
cout<<setw(15)<<"\tSIDES"<<setw(15)<<"TRIANGLE ?"<<setw(15)<<"PERIMETER"<<setw(15)<<"AREA\n" << endl;
Flag=false;
}
cout<<setw(15) << s1 << s2 << s3 <<setw(20)<<isatriangle(s1, s2, s3)<<setw(20)<<perimeter( s1, s2, s3 )<<setw(20)<< area(s1, s2, s3)<<"\n\n" <<endl;
}
return 0;
}
//function isatriangle definition
//x,y,z are parameters
bool isatriangle( double x, double y, double z){
return ((y + z > x) && (x + z > y) && (x + y > z)) ? true:false;
}
//function perimeter definition
// a,b,c are parameters
double perimeter ( double a, double b, double c ){
cout << setprecision(3);
cout << setiosflags(ios::fixed | ios::showpoint);
double p = (a + b + c);
return p;
}
//function semiperimeter definition
// a,b,c are parameters
double semiperimeter ( double a, double b, double c ){
double sp = (a + b + c )/2;
return sp;
}
//function area definition
// a,b,c, and are parameters
double area ( double a, double b, double c ){
cout << setprecision(3);
cout << setiosflags(ios::fixed | ios::showpoint);
double sp;
double B = sp * (sp-a)*(sp-b)*(sp-c);
double A = sqrt(B);
return A;
}