Question: Create a C + + program that contains the following namespaces: a . MathNamespace: This namespace will contain mathematical functions. b . StringNamespace: This namespace

Create a C++ program that contains the following namespaces:
a. MathNamespace: This namespace will contain mathematical functions.
b. StringNamespace: This namespace will contain string-related functions.
c. PrintNamespace: This namespace will contain functions related to printing.
In the MathNamespace, define the following functions:
a. int add(int, int): This function takes two integers as input and returns their sum.
b. int subtract(int, int): This function takes two integers as input and returns their difference.
c. int multiply(int, int): This function takes two integers as input and returns their product.
In the StringNamespace, define the following functions:
a. bool isPalindrome(string): This function takes a string as input and returns true if it is a palindrome (reads the same forwards and backward), otherwise returns false.
b. string reverseString(string): This function takes a string as input and returns a new string with its characters reversed.
In the PrintNamespace, define the following functions:
a. void printWelcomeMessage(): This function prints a welcome message to the console.
b. void printErrorMessage(string): This function takes a string as input and prints it as an error message.
Implement a simple menu-based system to interact with the namespaces:
a. Display a welcome message using the PrintNamespace.
b. Prompt the user to choose between math operations and string operations.
c. For math operations, prompt the user to enter two integers and choose between addition, subtraction, and multiplication using the MathNamespace. Display the result.
d. For string operations, prompt the user to enter a string and choose between checking for palindrome and reversing the string using the StringNamespace. Display the result.
The program should handle invalid inputs gracefully and provide appropriate error messages.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!