Programming assignment (100 pts): Rewrite your lab 3 calculator program using functions.
Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support in lab 3, please add additional functionality to your calculator. Include the ability to compute the factorial of an integer (Example: 4! = 1 * 2 * 3 *4 = 24), and an integer power of a number (Example: 53 = 5 * 5 * 5 = 125). Finally, add an interesting mathematical function of your choosing which computes the first n numbers of a sequence of numbers and utilizes an array to store the result before displaying it (Examples of mathematical sequences: Fibonacci, Primes).
Example of the output follows:
Calculator Menu:
- Addition
- Subtraction
- Multiplication
- Division
- Modulus (integers only)
- Test if prime (integers only)
- Factorial (integers only)
- Power
- Your function
- Exit
Please choose an operation: 8
Enter the first number: 5
Enter the second number: 3
5^3 = 125
Calculator Menu:
- Addition
- Subtraction
- Multiplication
- Division
- Modulus (integers only)
- Test if prime (integers only)
- Factorial (integers only)
- Power
- Your function
(0) Exit
Please choose an operation: 0 Good Bye!
You program MUST be bug-free, user friendly (verify input from the user), well commented
(Including author information, program description, lab section, date, etc.)
Reviews
There are no reviews yet.