Write a program that uses a random number generator to generate a two digit posi
ID: 3568036 • Letter: W
Question
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations:
a. Double the number.
b. Reverse the digits of the number.
c. Raise the number to the power of 2, 3, or 4.
d. Sum the digits of the number.
e. If the number is a two digit number, then raise the first digit to the power of the second digit.
f. If the number is a three digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit.
After performing an operation if the number is less than 10, add 10 to the number. Also, after each operation determine if the number is prime.
Each successive operation should be performed on the number generated by the last operation. Your program should not contain any global variables and each of these operations must be implemented by a separate function. Also, your program should be menu driven.
Need it written in C++.
Explanation / Answer
#include #include #include #include using namespace std; // Function Prototypes int doubleNumber(int x); int reverseNumber(int x); int raiseNumber(int x); int sumNumber(int x); int raiseFirstToSecondNumber(int x); int raiseFirstTwoToLastNumber(int x); int primeNumber(int x); int lessThanTen (int x); void printFunction(int x, int y); int main() { // Initialize variables int iRandom; int menuSelection; int primeYesNo; // Initialize random seed srand (time(NULL)); // Generate random number iRandom = rand() % 100; /* TEST CASE iRandom = 28; // PLACEHOLDER FOR RANDOM NUMBER = 28 *REMOVE**/ coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.