C CODE Need 2 functions please I know there are easier ways
C++ CODE: Need 2 functions please. I know there are easier ways to write this, but the functions must be done in this format.
/* This program is a collection of several functions that are to work together inside a
     do-while loop. There are more than 20 different functions, the 2 bellow I need help
     with. I have included the declarations I am using, but you might need to declare more.
     I just can\'t do this anymore! Thank you for your assistance*/
#include <iostream>
 #include <fstream>
 #include <cfloat>
 #include <iomanip>
 #include <climits>
 #include <cmath>
 #include <string>
using namespace std;
const double PI = 3.14157;
 void cylinderInfo(double length, double radius, double& surfaceArea, double& volume);
 bool sysStats_output(ofstream&, string);
int main()
 {
double length=0, radius=0, surfaceArea=0, volume=0;
 ofstream outFile;
    else if(userChoice == \'E\' || userChoice == \'e\'){
         cout<<\"\ ==============================================\ \";
           cout <<\"\ Enter cylinder RADIUS: \";
          //calculate surface area and volume of a cylinder
         // prompt user for info, and then call the cylinderInfo function
         //and display output
         cout<<\"\ ==============================================\ \";
          }
     else if(userChoice == \'G\' || userChoice == \'g\'){
      cout<<\"\ ==============================================\ \";
              outFile.close();
        //success in opening ouput file, and writing info
     if (sysStats_output(outFile, userName)){
       cout<<\"System Stats for user: \"<
     return 0;
 }
void cylinderInfo(double length, double radius, double& surfaceArea, double& volume){
     // calculate the surface area and volume of a cylinder
     surfaceArea= 0;
     volume = 0;
     }//end cylinder function
 ///===================== eNd-0f    return 0;-cylinderInfo ==================
 bool sysStats_output(ofstream& out, string name){
      // I have no idea how to finish this!!!!
     // create a string to hold the output file name, and
     // concatinate it with the text you want.
 return false;   //couldnt open and write to output file
 }
 ///===================== eNd-0f-sysStatsOutput ==================
Solution
Hi, PLease find my implementation.
Please let me know in case of any issue.
You have not posted complete code, so i am not able to run this program.
#include <iostream>
 #include <fstream>
 #include <cfloat>
 #include <iomanip>
 #include <climits>
 #include <cmath>
 #include <string>
 using namespace std;
 const double PI = 3.14157;
void cylinderInfo(double length, double radius, double& surfaceArea, double& volume);
 bool sysStats_output(ofstream&, string);
 int main()
 {
 double length=0, radius=0, surfaceArea=0, volume=0;
 ofstream outFile;
 else if(userChoice == \'E\' || userChoice == \'e\'){
 cout<<\"\ ==============================================\ \";
  cout <<\"\ Enter cylinder RADIUS: \";
 //calculate surface area and volume of a cylinder
 // prompt user for info, and then call the cylinderInfo function
 //and display output
 cin>>radius;
 cout <<\"\ Enter cylinder height: \";
 cin>>length;
// calling function
 cylinderInfo(length, radius, surfaceArea, volume);
cout<<\"Surface Area: \"<<surfaceArea<<endl;
 cout<<\"Volume: \"<<volume<<endl;
 cout<<\"\ ==============================================\ \";
  }
else if(userChoice == \'G\' || userChoice == \'g\'){
 cout<<\"\ ==============================================\ \";
  outFile.close();
 //success in opening ouput file, and writing info
 if (sysStats_output(outFile, userName)){
 cout<<\"System Stats for user: \"<
return 0;
 }
 void cylinderInfo(double length, double radius, double& surfaceArea, double& volume){
 // calculate the surface area and volume of a cylinder
 surfaceArea= 0;
 volume = 0;
// Surface Area: A=2r(h+r)
 surfaceArea = 2*PI*radius(length + radius);
// Volume: r^2h
 volume = PI*radius*radius*length;
}//end cylinder function
 ///===================== eNd-0f return 0;-cylinderInfo ==================
bool sysStats_output(ofstream& out, string name){
 // I have no idea how to finish this!!!!
 // create a string to hold the output file name, and
 // concatinate it with the text you want.
string outFileName;
 cout<<\"Enter output file name: \";
 cin>>outFileName;
// opening out stream
 out.open(outFileName.c_str());
if(out.fail()){
 return false; //couldnt open and write to output file
 }
// writing name in output file
 out<<name;
// closing out
 out.close();
return true;
 }
 ///===================== eNd-0f-sysStatsOutput ==================



