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 133
|
#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);
long int funcTwo(long int, long int);
long double funcThree(long double, int, long int);
long int funcFour(long int, long int);
long double funcFive(string, long double, long int);
long double funcSix(string, long double, long int);
long int addTen(long int, long int, int);
void isPrime(long int, int);
bool validInput();
void cleanup();
int main()
{
int randNum, choice, choice2, divisor;
long int currentNum, add, doubledNum;
long double reversedNum = 0;
long double poweredNum;
long int sumOfNum = 0;
string firstToSecond, secondToThird;
long double twoDigitPowered, threeDigitPowered;
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";
if (validInput())
{
menuOptions();
cin >> choice;
cout << "\n";
}
while(choice != 0)
{
switch(choice)
{
case 1:
currentNum = funcOne(doubledNum, currentNum);
cout << "Doubled = " << currentNum
<< "\n\n";
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case 2:
currentNum = funcTwo(reversedNum, currentNum);
cout << "Reversed Number = " << currentNum
<< "\n\n";
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case 3:
cout << "Raise to the power of 2, 3, or 4?: ";
cin >> choice2;
cout << "\n";
if (choice2 == 2 || choice2 == 3 || choice2 == 4) //prevents bugging
currentNum = funcThree(poweredNum, choice2, currentNum);
cout << currentNum
<< "\n\n";
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case 4:
currentNum = funcFour(sumOfNum, currentNum);
cout << "Sum of the digits of the number = "
<< currentNum << "\n\n";
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case 5:
currentNum = funcFive(firstToSecond, twoDigitPowered, currentNum);
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case 6:
currentNum = funcSix(secondToThird, threeDigitPowered, currentNum);
currentNum = addTen(currentNum, add, divisor);
isPrime(currentNum, divisor);
break;
case -1:
goto START;
break;
default:
cout << "Invalid Choice!\n\n" << "Current Number: "
<< currentNum << "\n";
break;
}
if (validInput())
{
menuOptions();
cin >> choice;
cout << "\n";
}
cleanup();
menuOptions();
cin >> choice;
cout << "\n";
}
return 0;
}
|