Building a Looping Calculator
Building a calculator requires knowledge in "if statements", "while going statements", and an understanding of integers and floats. The picture to the right is the blue-print.
Building a Looping Calculator
Building a calculator requires knowledge in "if statements", "while going statements", and an understanding of integers and floats. The picture to the right is the blue-print.
Attempt #1-
This is my first attempt at trying to make this calculator. The first three lines of the code make perfect sense, as I specify the operator and two variables. However, the input would not have word, so an "if statement" is required.
Attempt #2-
I added an "if statement" for each type of operator: addition, subtraction, multiplication, and division. I said "if" a few lines in a row. You first use "if", then "elif" (as many as needed), then "end" with else if. I used the term "float" instead of "integers" because integers are used only for whole numbers, while floats can be used for whole numbers AND decimals.
Attempt #3-
I still have an error, though, because the operator signs specifically are not in quotations. I have also replaced the "if" words with the appropriate terms.
Attempt #4
I have successfully created a calculator that adds, subtracts, multiples, and divides two numbers of my choice. But, I want to take it a step further, and have it loop. What this means is, after I get the answer I want, I want the opportunity to type in another equation.
Attempt #5
I added the "while going" statements in the beginning and end of the code. I have an error because I did not add a ":" in the second line. Additionally, I did not indent properly.
Attempt #6
I have added the ":" and the proper indentation. However, I did not indent the last two lines, so my code is stuck in the loop seen above.
Attempt #7
After I indented the last two lines, I have now created a successful, working calculator that I can keep inserting equations into if I type in "y", and have it stop if I type in "no".