1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <string>
using namespace std;
int randomNumGenerator(int);
void menuOptions();
long int funcOne(long int, long int); //1
long int funcTwo(long int, long int); //2
long double funcThree(long double, int, long int); //3
long int funcFour(long int, long int); //4
long double funcFive(string, string, string, long double, long int); //5
long double funcSix(string, long double, long int); //6
long int addTen(long int, long int);
void isPrime(long int, int);
void validInput();
void cleanup();
int main()
{
int randNum, choice, choice2, divisor;
long int currentNum;
long int doubledNum;
long double reversedNum = 0;
long double poweredNum;
long int sumOfNum = 0;
string firstToSecond, num1, num2;
string secondToThird;
long double twoDigitPowered, threeDigitPowered;
long int add;
START:
cout << fixed << showpoint << setprecision(2) << endl;
cout << "The following random number is generated: ";
currentNum = randomNumGenerator(randNum);
cout << currentNum;
cout << "\n\n";
isPrime(currentNum, divisor);
menuOptions();
cin >> choice;
cout << "\n";
do
{
switch(choice)
{
case 1:
cout << "Doubled = " << funcOne(doubledNum, currentNum)
<< "\n\n";
currentNum = funcOne(doubledNum, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
isPrime(currentNum, divisor);
break;
case 2:
cout << "Reversed Number = " << funcTwo(reversedNum, currentNum)
<< "\n\n";
currentNum = funcTwo(reversedNum, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
isPrime(currentNum, divisor);
break;
case 3:
cout << "Raise to the power of 2, 3, or 4?: ";
cin >> choice2;
cout << "\n";
cout << funcThree(poweredNum, choice2, currentNum)
<< "\n\n";
if (choice2 == 2 || choice2 == 3 || choice2 == 4) //prevents bugging
currentNum = funcThree(poweredNum, choice2, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
isPrime(currentNum, divisor);
break;
case 4:
cout << "Sum of the digits of the number = "
<< funcFour(sumOfNum, currentNum) << "\n\n";
currentNum = funcFour(sumOfNum, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
isPrime(currentNum, divisor);
break;
case 5:
{ cout << "First Digit raised to Second Digit = "
<< funcFive(firstToSecond, num1, num2, twoDigitPowered, currentNum)
<< "\n\n";
currentNum = funcFive(firstToSecond, num1, num2, twoDigitPowered, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
}
isPrime(currentNum, divisor);
break;
case 6:
{ cout << "First two digits raised to the third digit = "
<< funcSix(secondToThird, threeDigitPowered, currentNum)
<< "\n\n";
currentNum = funcSix(secondToThird, threeDigitPowered, currentNum);
addTen(currentNum, add);
currentNum = addTen(currentNum, add);
}
isPrime(currentNum, divisor);
break;
case -1:
goto START;
default:
cout << "Invalid Choice!\n\n" << "Current Number: "
<< currentNum << "\n";
}
cleanup();
menuOptions();
cin >> choice;
cout << "\n";
}
while (choice != 0);
return 0;
}
|