Question
Please write in C that can be used in Eclipse program Write a calculator program. Your calculator should provide at least four simple math operations
Please write in C that can be used in Eclipse program
Write a calculator program. Your calculator should provide at least four simple math operations (e.g. addition, subtraction, multiplication, etc.) and two advanced math functions (e.g. sine, power, log). In the following example, weve implemented addition, subtraction, multiplication, and division. The program will ask the user to enter a number, enter a symbol to indicate which function (+, -, *, or /), and then enter the second number in the equation. The calculator should take FLOATING POINT numbers as input and output. Therefore, all numbers you store in memory (input and output) will be float or double (your choice). Consider the following example:
The Simple Calculator
Enter your first number: 28
Enter an operation (+, -, *, /, (s)ine, or (p)ower): /
Enter your second number: 4
The result of 28.0000 / 4.0000 is 7.0000
Your program will display the numbers entered, the operator, and the answer. This isnt the only way to design the calculator interface. You may prefer something different. Here is another example:
The Simple Calculator
Valid input:
- Two numbers with the operand in the middle (ex: 3 + 2). Enter an equation: 28 / 4
The result of 28.0000 / 4.0000 is 7.0000
Advanced Math: Implement two advanced math functions, such as sine, power, etc. Lookup the functions available in math.h. Youll need to add an import statement for math.h to use these functions.
Implement your own advanced math function to compute 2x . (Do not use a library function to solve.) To receive the bonus credit, you must create a separate function outside of main(). The function should take in an integer x and return 2x . When the user selects the 2x operation, your calculator program should not ask the user to enter a second number.
HINT: Refer to the bitwise operations you used in Lab #2 for a quick way to compute the solution.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started