#include <iostream>
#include <cmath>
int main()
{
char function = ' ';
double val = 0;
double theResult;
std::cout << "This calculator requires you to enter a funtion and a number\n";
std::cout << "The functions are as follows:\n";
std::cout << "S - sine\n";
std::cout << "C - cosine\n";
std::cout << "T - tangent\n";
std::cout << "R - square root\n";
std::cout << "N - natural log\n";
std::cout << "X - exit the program\n";
while (function != 'X') // notice X is uppercase, not lowercase
{
std::cout << "\nPlease enter a function and a value: ";
std::cin >> function;
std::cin >> val;
function = (toupper(function));
switch (function)
{
case'S':
theResult = sin(val);
std::cout << "The sine of your number is " << theResult << "\n";
break;
case'C':
theResult = cos(val);
std::cout << "The cosine of your number is " << theResult << "\n";
break;
case'T':
theResult = tan(val);
std::cout << "The tangent of your number is " << theResult << "\n";
break;
case'R':
theResult = sqrt(val);
std::cout << "The square root of your number is " << theResult << "\n";;
break;
case'N':
theResult = log(val);
std::cout << "The natural log of your number is " << theResult << "\n";
break;
case'X':
break;
}
}
return 0;
}