+ 1

Hi does anyone knows how to give me a tip on coding a calculator

I'm a newby and I need help on this if can give me an advice I'll be very thankful

17th Dec 2022, 5:42 PM
Amirarsalan Jalalvand
Amirarsalan Jalalvand - avatar
2 Answers
+ 6
Sure Here are a few tips to help you get started. -Start by identifying the basic operations you want your calculator to perform, such as addition, subtraction, multiplication, and division. -Next, think about how you will take input from the user. One approach is to have the user enter the numbers and the operation they want to perform (e.g. "2 + 3") as a single string, and then parse that string to extract the numbers and operation. -Create variables to store the numbers and the operation the user has entered. -Write a function that takes the two numbers and the operation as arguments and returns the result of the calculation. -Use a loop to continuously prompt the user for input and output the result of the calculation until the user decides to exit the program. -Consider adding error handling to your code, so that the calculator can handle invalid input or operations gracefully
17th Dec 2022, 6:34 PM
Sadaam Linux
Sadaam Linux - avatar
+ 1
Prompt the user to enter 1- number 2- Operator 3- number Then evaluate and validate the operator sign using if else statement to print the result or an error. Hint: user input return string type.
17th Dec 2022, 6:18 PM
iTech
iTech - avatar