/*********************************** * TANDYWP.CPP * ***********************************/ #include #include void Cube(long double Number) { long double Cubes; Cubes = Number * Number * Number; cout << "The cube of " << Number << " is: " << Cubes << ". \n"; } void Square(long double Number){ long double Squares; Squares = Number * Number; cout << Squares << " is the square of " << Number << ". \n"; } void SquareRoot(long double Number) { if (Number < 0) { throw "Can't square root negative number.\n"; } cout << "The square root of " << Number << " is: " << sqrtl(Number) << ". \n"; } void Power(long double Number) { long double ToPower; long double huh; cout << "What power do you wish to raise your number to?"; cin >> huh; ToPower = exp(huh * log(Number)); cout << Number << " raised to the " << huh << "th power is: " << ToPower << ". \n"; } void CubeRoot(long double Number) { long double CubeRoots; CubeRoots = exp(1./3. * log(Number)); cout << "The cube root of " << Number << " is: " << CubeRoots << ". \n"; } void MultiRoot(long double Number) { if (Number < 0) { throw "Can't perform requested function. \n"; } long double MultiRoots, huh; cout << "Enter the root to which you wish to lower your number: "; cin >> huh; MultiRoots = exp(1./huh * log(Number)); cout << "The " << huh << "th root root of " << Number << " is: " << MultiRoots << ". \n"; } //this function shows the designer, year of creation, and purpose of TandyWP void OpeningSequence() { cout << "TandyWP v2.1. \n"; cout << "Created 1996 by Warren Myers. \n"; cout << "Updated 2001 by WMM. \n\n"; cout << "TandyWP is an interactive math program that gives you a choice of \n" << " up to six different things to be done to a number that you type in. \n\n"; } //this is the main() of the program long double main(void) { long double Number; OpeningSequence(); //call the openingsequence function int choice = 7; cout<> Number; if (Number <0) { cout << "Unknown results in operations. \n"; cout << "Dangerous outcomes if you choose numbers 5 or 6 as " ; cout << "your operation. \n"; } cout << "What operation do you wish to be accomplished? \n"; cout << "Cube 1 \n"; cout << "Square 2 \n"; cout << "Raise to power 3 \n"; cout << "Cube root 4 \n"; cout << "Multiple root 5 \n"; cout << "Square root 6 \n"; cout << "Quit 0 \n"; cin >> choice; switch (choice) { case 0: // just quit now exit(0); case 1: Cube(Number); break; case 2: Square(Number); break; case 3: Power(Number); break; case 4: CubeRoot(Number); break; case 5: try { MultiRoot(Number); } catch (char *warning) { cout << warning; } break; case 6: try { SquareRoot(Number); } catch (char *warning) { cout << warning; } break; default: cout << "Illegal function attempt. \n"; } cout << "Another number? y/n "; char chk; cin >> chk; if(chk == 'n' || chk == 'N') break; } }