// ***********************************************************************
while (menuoptions !== '1','2','3','4','5','0')
{
cout << "Please select a menu item (0-5): ";
cin >> menuoptions;
}
if ( menuoptions != '0')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '1')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '2')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '3')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '4')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '5')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;
switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
}
{
}
} while (menuoptions='0');
// ************************************************************************
return 0;
}
// *********************************************************************
// * Your functions that do the square root, absolute value, log, inverse, an
// * cube go here. // **********************************************************************
void showmenu()
{
cout<< "M E N U" <<endl;
cout<< "1 - Calculate Square Root" <<endl;
cout<< "2 - Calculate Cube" <<endl;
cout<< "3 - Calculate Natural Logarithm" <<endl;
cout<< "4 - Calculate Inverse" <<endl;
cout<< "5 - Absolute Value" <<endl;
cout<< "0 - Exit Program" <<endl;
cout<< "Enter Menu Option ";
}
1. missing semicolons, yes you need one at the end of the declaration void cube(double userinput);
2. Capitalization errors: AbsValue and absvalue are different names in C++
3. Spelling errors (menuoptions is misspelled many times)
4. You need to change the name of your function log, log is already defined in the math library.
5. There is a problem with the switch (menuoptions), menuoptions is defined as a char and the switch expects a numeric value. The char '5' is not the integer 5. You can instead write switch(menuoptions - '0') , this trick forces the conversion to an integer.
6. I have not really tried to understand the overall program but it is repetitive, which suggests there is probably something wrong with the structure and you should be able to simplify it with the correct loop.
The code tags mentioned by jlb are [code] before the code and /code between [] at the end of the code