hi, I am writing a simple calculator program and want to know how to write my nested if conditions for perfroming calculations
hi, I am writing a simple calculator program and want to know how to write my nested if conditions for perfroming calculations
I'm not sure what you mean by nested if conditions. Why do you have a need to write nested ifs (unless it's because that's what your teacher is asking for?)
Can you give us a little more information as to what you want your calculator to do, as well as how you want it to function, and what you have done so far or where you need help. In other words, will there be a UI? Will it ask you what operation you want to perform, and then ask you for the numbers? Or will it be a textbox and you simply type whatever calculations you want?
For example, here's pseudocode for one type of simple calculator app:
Prompt user for what type of calculation (addition, subtraction, etc.)
Prompt user for two numbers
if (user entered addition)
{
Add the 2 numbers and spit out the result
}
else if (user entered subtraction)
{
Calculate the difference between the 2 numbers and spit out the result
}
else if ...
Not sure where nested ifs would come into play if you go down that route.
I also don't see it where the nested ifs would fit in.
Could you show us the code you already have?
Maybe it is just a few lines, maybe it's not working, we don't care.
But it would help us better to help you! :)