what are listed below is my program about the homework, but I don't what's wrong with it, it doesn't work/
Code:
#include <iostream>
#include <cmath>
using namespace std;
//declarations of functions
double processArgs(double x, double y);//two operands function
double processArgs(double x);//one operand function
void print(double x,double y);//two operands print functions
void print(double x)// one operands print functions
int processchoice();//a function to process menu or user choice
//main function
int main ()
{
int choice;// menu choice
double x,y,result;
do {
choice=processchoice();
swith(choice)
case 1:result=processArgs(x,y);
cout<<print(x,y)<<result<<endl;
break;
case2:
result=processArgs(x);
cout<<print(x)<< result<<endl;
break;
if (choice==3) break;//quit the program
} while (choice!=3);
return 0;
}
//The functions to support the main program above are below
int processchoice() {
int choice;
cout<<"1) Enter two-argument expression"<<endl;
cout<<"2)Enter one-argument expression"<<endl;
cout<<"3)quit program"<<endl;
cin>>choice;
return(choice);
}
double processArgs(double x, double y) {
char op;
double result;
cout<<"chose your operator";
cout<<"+:add"<<endl;
cout<<"-:subtract"<<endl;
cout<<"*:multiply"<<endl;
cout<<"/:devide"<<endl;
cout<<"^:power"<<endl;
cin>>op;
switch(op) {
case '+': result=x+y;
break;
case '-': result=x-y;
break;
case '*': result=x*y;
break;
case'/':
if (y!=0)
result=x/y;
else
cout<<"Don't try to divide by zero"<<endl;
break;
case'^': result=pow(x,y);
break;
}
return(result);
}
double processArgs(double x) {
char op;
double result;
cout<<"S:squar"<<endl;
cout<<"E:exponential"<<endl;
cout<<"L: natural logarithm"<<endl;
cout<<"chose your operator"<<endl;
cin>>op;
switch(op) {
case 'S':
result=sqr(x);
break;
case 'E':
result=exp(x);
break;
case 'L':
result=log(x);
break;
}
return(result);
}
void print(double x,double y) {
char op;
cout<<"Enter an X op Y expression: << x << op<<y<<endl;
cout<< x<<op<<y<<"=";
}
void print(double x) {
char op;
cout<< " Enter an op X style expression: " << op << x << endl;
cout << op <<x<<"=";
}