Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. 3 Write a function clunkyCalculator that, when called, will perform the basic tasks of a calculator (addition, subtraction, multiplication, and division) for two numbers.
3. 3 Write a function clunkyCalculator that, when called, will perform the basic tasks of a calculator (addition, subtraction, multiplication, and division) for two numbers. The user should be asked to enter the first number, then the operator to use, and then the second number, and the program should output the correct result. Note that the numbers might not be integers. This function should loop, asking the user if they want to perform another calculation, and if so, repeating the process above. If the user does not want to continue, the program should output "Bye!" and then exit the loop. The casing of the user's response to this question should be ignored. To help with this, write a function calculate that takes 3 inputs (the first number, the operator as a String, c.g. "+", and the sccond number) and returns the correct answer. For example, calculate(2,"*",3.2) would calculate 2 * 3.2 and return the number 6.4. Up to 5 marks will be awarded for flair, i.e., useful functionality that is in addition to that requested in this question. Include comments in your code to explain what is happening. The example below shows how your function should behave: (50 marks] clunkyCalculator(); // put this in setup() // in Serial Monitor Please enter your calculation First number: 12.00 Operator: + Second number: 7.10 - 19.10 Do you want to perform another calculation? Yes Please enter your calculation First number: 11.50 Operator: / Second number: 7.00 1.64 Do you want to perform another calculation? no Bye
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