Pt1420 Unit 8

Improved Essays
Initial Goals: My initial goals for the program was to take in an equation like 5*(4/3+2^(3-1)) and return the answer to it (26.666667 in this case). I intended it to work with simple arithmetic (multiplication, division, addition, subtraction, exponents, and parentheses). My initial brainstorming resulted in an iterative action. The program would follow the order of operations and begin with the contents of innermost parentheses and replace that portion of the input with the answer before moving one step out into what is now the innermost parentheses. The program would move up a level each time until there are no more levels, leaving (hopefully) the answer.
Current Specifications: The program works as expected. It will return answers to
…show more content…
Both versions accept a string variable as the first argument. One of the versions accepts a string to be output to cout for the user to read before prompting the user for input. The input will be assigned to the string variable provided by the first argument. Paren returns a string of the contents of the innermost parentheses of the provided string (first argument). The integer variable provided in the second argument will be assigned the position of the opening parenthesis of the parentheses that is around the string returned by the function. The third argument is an integer and is assigned a vale to indicate the position of the closing …show more content…
Anything it doesn’t do is purely by design. I could add other mathematical functions, like sin, cos, tan, factorials, etc. I could also add something to assume when the user leaves a number next an opening parenthesis with no operator in between they mean the two should be multiplied. A white space stripper could also be added so white space could be used in the input without changing any of the rest of the program. I’m sure I could have improved the program. I’m sure I could condense the code down a bit or make it more easily read. I could have gone with a different overall motion to the program. It’s a bit similar to the iterative action of my program. It would likely end up nesting Calculate. When a parentheses is encounter a new instance of Calculate would be called up to deal with the contents of that one. Eventually the program would get down to the innermost parentheses and return that answer up a level so that instance can solve its

Related Documents

  • Decent Essays

    Pt1420 Unit 6 Lab

    • 109 Words
    • 1 Pages

    One thing that definitely went wrong in the lab was that we had to round about two of our measurements and the reason being was that they were exact. To exemplify, when we were reading the volume for the finishing measurement of the base for trial three, we got exactly 45.00 mL. The only problem was that, we had didn’t really have the two significant decimal numbers. Hence, we rounded our volume to 45.01 mL. Also, we got exactly 23.00 mL for our finishing volume of the acid for trial three. Therefore, once again we rounded it to 23.02mL in order to get at least two significant decimal numbers.…

    • 109 Words
    • 1 Pages
    Decent Essays
  • Improved Essays

    Pt1420 Unit 7 Checkpoint

    • 517 Words
    • 3 Pages

    The findings associated with this experiment are quantitative, meaning that they were broken down into a “numerical representation and manipulation of observations for the purpose of describing and explaining the phenomena that those observations reflected” (Babbie, 2015, 494). The data was then compiled utilizing Micrsoft Excel, this allowed for individual charts to be created to visually represent the data accuratly, See Figure 1, Figure 2, Figure 3, and Figure 4. Each chart has a different representation. Figure 1 illustrates the findings of the pre-test wich indicate that each participant with the exclusion of two were not able to list all 50 states. Additionally, Massachusets and Iowa were most commonly missed and with the inclusion of Hawaii, Minnesota, Texas, Nevada, and California the participants were also able…

    • 517 Words
    • 3 Pages
    Improved Essays
  • Improved Essays

    Pt1420 Unit 7

    • 231 Words
    • 1 Pages

    Interpret the data displayed in the SPSS output graphs you created. 90 children obtained trauma- informed counseling services. Children age 10 is the highest (mode) and the average (mean) age group to obtain service. The standard deviant is 3.3.…

    • 231 Words
    • 1 Pages
    Improved Essays
  • Improved Essays

    9/11 Math Short Story

    • 511 Words
    • 3 Pages

    Ryan- Hello and welcome to X+Y math news at 9:30!!!! Our top story - during a fight, 5 and 6 divided. The whole problem is negative 5/6k=12. to help find what k= our mathematicians have done the following steps.…

    • 511 Words
    • 3 Pages
    Improved Essays
  • Improved Essays

    Bingo Order Of Operations

    • 529 Words
    • 3 Pages

    To introduce the concept of order of operations to the students I would first write PEMDAS on the board which stands for Parentheses, Exponents, Multiplication, Division, Addition and Subtraction. I would put brackets around M and D, and A and S, to show that they are grouped together in the order of operations. “One misconception by students is that all multiplication should happen before all division because the multiplication comes before division in the acronym. In fact, multiplication and division have the same precedence and should be evaluated as they appear from left to right.”(NCTM) I would explain to them that we are going to go over a few expressions using the order of operations then we are going to play a game of bingo using the order of operations.…

    • 529 Words
    • 3 Pages
    Improved Essays
  • Decent Essays

    Central Processing Unit (CPU): The CPU is the brain of a computer, where it “fetches each program instruction from memory and carries out and executes the instruction”. On a technical level the top three components of a CPU are: 1. Arithmetic Logic Unit (ALU):…

    • 376 Words
    • 2 Pages
    Decent Essays
  • Decent Essays

    I think Quick Slither is the best multiplication game there is. I think it is the best because it teaches you the facts you need to know in a quick pace. Quick slither also lets you have fun while learning because you are answering facts to get away from the snake. It can also give you coins to buy accessories like things for your tree and stuff to wear like hats,shirts,etc in reflex. There are lots of ways to have fun while you're answering multiplication facts.…

    • 159 Words
    • 1 Pages
    Decent Essays
  • Improved Essays

    John Backus Essay

    • 1137 Words
    • 5 Pages

    His determination produced a function-level language, or FP for functional programming. FP was a style of programming that modeled computations as the evaluation of expressions, in contrast to the imperative programming that contained programs composed of statements which would change global state when executed. It was in 1977 that Backus first introduced this language to the public, in which during the lecture “Can Programming be Liberated from the Von Neumann Stype? A Functional Style and Its Algebra of Programs,” he proposed the FP. Functional Programming was able to provide better support for structured programming, and offered shorter programs that were easier to understand than the opposing imperative programs.…

    • 1137 Words
    • 5 Pages
    Improved Essays
  • Improved Essays

    Graphing Calculator Essay

    • 2077 Words
    • 9 Pages

    During the 2015-16 school year, Steve was an attentive student. In the second semester, he decided to count how many people in his class would lose or destroy their graphing calculators. Of the 15 people in his math class, in the second semester, 3 people lost their graphing calculator. Over the summer, Steve realized that if he assumed that there were 40 students in each grade in high school, then that was a total of 160 students. Steve realized that every mathematics course in high school required a graphing calculator, meaning that all high school students need a graphing calculator.…

    • 2077 Words
    • 9 Pages
    Improved Essays
  • Great Essays

    Leibniz's Number System

    • 1190 Words
    • 5 Pages

    Computers have all but replaced humans for doing complex calculations. But computers handle numbers much differently than humans do. At this point, the majority of people use base-10 for their math. The base of a number system refers to the number of number symbols used in that system. In base 10 the numbers used are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.…

    • 1190 Words
    • 5 Pages
    Great Essays
  • Superior Essays

    Example Of Factor Graph

    • 1292 Words
    • 6 Pages

    Factor graph: A factor graph is a type of probabilistic graphical model. A factor graph has two types of nodes: Variables, which can be either evidence variables when their value is known, or query variables when their value should be predicted. Factors, which define the relationships between variables in the graph. Fig. 2.13 shows an example of factor graph.…

    • 1292 Words
    • 6 Pages
    Superior Essays
  • Improved Essays

    Divide and Conquer Strategies: Divide and conquer is an algorithm which design paradigm based on multi-branched recursion. This designed paradigm consists of following phases: 1) Break the problem (divide): Breaking the problem into several sub-problems that are smaller in size. 2) Solve the sub problem(conquer) : Solve the sub-problem recursively .…

    • 718 Words
    • 3 Pages
    Improved Essays
  • Great Essays

    • dotimes is similar to dolist but instead of iterating over the values of a list, it iterates the value of a variable up to a specified count. The value of the variable ranges from 0 to specified count – 1. • do is a flexible iterator construct and can be used to replace dotimes and dolist. Unlike dotimes and dolist which provides only one loop variable do supports an arbitrary number of loop variables. • loop is an iterator when coupled with constructs like when, for, while, finally… called as extended loop and loop without them is called a simple loop. A simple loop is an infinite loop whereas extended loop can be made as a finite loop.…

    • 2310 Words
    • 10 Pages
    Great Essays
  • Improved Essays

    One of the most influential tools that the human race has to offer is the calculator. The calculator is an asset that helps people perform various arithmetic functions such as addition or division. Over the years, the functionality and the apparel of the calculator have evolved over time. In fact, the history of the calculator can even date back before the years of 1900. Ancient civilizations such as Egypt, Middle East, and even Europe had their own variation of the calculator.…

    • 804 Words
    • 4 Pages
    Improved Essays
  • Great Essays

    Introduction: This Research problem is aiming to compare and contrast four programming languages according to programming paradigms and the features with the purpose of determining the suitability and applicability of the languages for each criterion, distinguish them with their pros and cons, evaluate and explore the related features on those languages. For this I have selected one language from each programming paradigm (imperative, object-oriented, functional, logic) and compared it with the Iterative statements feature. The comparing and contrasting is based on the following design characteristics:…

    • 1825 Words
    • 8 Pages
    Great Essays