#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
char function;
double val;
cout << "This calculator requires you to enter a funtion and a number" << endl;
cout << "The functions are as follows: " << endl;
cout << "S - sine " << endl;
cout << "C - cosine " << endl;
cout << "T - tangent " << endl;
cout << "R - square root " << endl;
cout << "N - natural log " << endl;
cout << "X - exit the program " << endl;
cout << endl;
cout << "Please enter a function and a value " << endl;
cin >> function;
cin >> val;
function = (toupper(function));
while (toupper(function) != 'x')
{
double theSin = sin(val);
double theCos = cos(val);
double theTan = tan(val);
double theSqrt = sqrt(val);
double theLog = log(val);
switch (function)
{
case'S':
cout << "The sine of your number is " << theSin << endl;
break;
case'C':
cout << "The cosine of your number is " << theCos << endl;
break;
case'T':
cout << "The tangent of your number is " << theTan << endl;
break;
case'R':
cout << "The square root of your number is " << theLog << endl;
case'X':
exit(0);
}
}
return 0;
}
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
char function;
double val;
do
{
cout << "This calculator requires you to enter a funtion and a number" << endl;
cout << "The functions are as follows: " << endl;
cout << "S - sine " << endl;
cout << "C - cosine " << endl;
cout << "T - tangent " << endl;
cout << "R - square root " << endl;
cout << "N - natural log " << endl;
cout << "X - exit the program " << endl;
cout << endl;
cout << "Please enter a function and a value " << endl;
cin >> function;
cin >> val;
function = (toupper(function));
double theSin = sin(val);
double theCos = cos(val);
double theTan = tan(val);
double theSqrt = sqrt(val);
double theLog = log(val);
switch (function)
{
case'S':
cout << "The sine of your number is " << theSin << endl;
break;
case'C':
cout << "The cosine of your number is " << theCos << endl;
break;
case'T':
cout << "The tangent of your number is " << theTan << endl;
break;
case'R':
cout << "The square root of your number is " << theLog << endl;
case'X':
exit(0);
}
} while (function != 'x');
return 0;
}
#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;
}