Introduction to Programming Languages CECS130 Lab 4

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (5 votes)

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:
(1) Addition
(2) Subtraction
(3) Multiplication
(4) Division
(5) Modulus (integers only)
(6) Test if prime (integers only)
(7) Factorial (integers only)
(8) Power
(9) Your function
(0) Exit
Please choose an operation: 8
Enter the first number: 5
Enter the second number: 3
5^3 = 125
Calculator Menu:
(1) Addition
(2) Subtraction
(3) Multiplication
(4) Division
(5) Modulus (integers only)
(6) Test if prime (integers only)
(7) Factorial (integers only)
(8) Power
(9) 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.)