I have a program for class that performs various arithmetic operations including: addition, subtraction, multiplication, division, exponents, and factorials. I have to use an infile with a switch statement that calls the functions to perform the operations. I have no idea how to do the functions part. Also every time I try to run my program, the file doesn't open. I'm not sure how the rest of my program looks, but all help is appreciated, and half of it was given from my teacher for us to use. I only need this class for my major, I'm not going into computer science so this is really difficult for me to grasp.
inFile.open( "math.txt" );
if( inFile.fail() )
{
cout<<"The math.txt input file failed to open";
exit(-1);
}
//Read the first operation type from the input file
inFile >> ch;
//While there are mathematical operations to be performed
while ( inFile )
{
switch (ch)
{
case '+':
void doAddition(ifstream &inFile);
break;
case '-':
void doSubtraction(ifstream &inFile);
break;
case '*':
void doMultiplication(ifstream &inFile);
break;
case '/':
void doDivision(ifstream &inFile);
break;
case '^':
void doExponent(ifstream &inFile);
break;
case '!':
void doFactorial(ifstream &inFile);
break;
default: "\nInvalid Operation";
inFile.ignore(100, '\n');
break;
}
} //switch statement that will call various functions based on the
//operator contained in the ch variable
//Get the next operation type from the input file
inFile >> ch;
inFile.close ();
return 0;
}