Professional Documents
Culture Documents
Text
Text
Matric no:2009003121
Name:shotonwa gbolahan olumide
#include <iostream>
#include <cmath>
using namespace std;
int solve();
int Continue();
int Continue() {
char res;
cout << "Do you want to continue? (y/n) ";
cin >> res;
switch (res) {
case 'y':
case 'Y':
solve();
break;
case 'n':
case 'N':
cout << "---End of program, have a wonderful day---" << endl;
break;
default:
cout << "You entered an invalid answer (y/n)." << endl;
}
return 0;
}
int solve() {
cout << "Hi there, this program collects theta values and calculates
its sine, cosine, secant, tangent, and cotangent values respectively" <<
endl;
int thetaVal;
string op; // Change op to a string
cout << "Please input your theta value: ";
cin >> thetaVal;
cout << "What operation do you want to perform on the theta value
(sin, cos, sec, tan, or cotan): ";
cin >> op;
if (op == "sin") {
double convertVal = sinFunc(thetaVal);
cout << "The sine value of " << thetaVal << " is " << convertVal
<< endl;
Continue();
} else if (op == "cos") {
double convertVal = cosFunc(thetaVal);
cout << "The cosine value of " << thetaVal << " is " <<
convertVal << endl;
Continue();
} else if (op == "sec") {
double convertVal = secFunc(thetaVal);
cout << "The secant value of " << thetaVal << " is " <<
convertVal << endl;
Continue();
} else if (op == "tan") {
double convertVal = tanFunc(thetaVal);
cout << "The tangent value of " << thetaVal << " is " <<
convertVal << endl;
Continue();
} else if (op == "cotan") {
double convertVal = cotanFunc(thetaVal);
cout << "The cotangent value of " << thetaVal << " is " <<
convertVal << endl;
Continue();
} else {
cout << "You typed an invalid operation (sin, cos, sec, tan,
cotan)" << endl;
}
return 0;
}
int main() {
solve();
return 0;
}