Math Challenge Have the function MathChallenge(str) take the str parameter being passed and evaluate the mathematical expression within in. For example, if str were "2+(3-1)3" the output should be 8. Another example: if str were "(2-0)(6/2)" the output should be 6. There can be parenthesis within the string so you must evaluate it properly according to the rules of arithmetic. The string will contain the operators: +, -, /, , (, and ). If you have a string like this: #/## or #+#(#)/#, then evaluate from left to right. So divide then multiply, and for the second one multiply, divide, then add. The evaluations will be such that there will not be any decimal operations, so you do not need to account for rounding and whatnot. Examples Input: "6(4/2)+3*1" Output: 15 Input: "6/3-1" Output: 1
-
Notifications
You must be signed in to change notification settings - Fork 3
Have the function MathChallenge(str) take the str parameter being passed and evaluate the mathematical expression within in. For example, if str were "2+(3-1)*3" the output should be 8. Another example: if str were "(2-0)(6/2)" the output should be 6. There can be parenthesis within the string so you must evaluate it properly according to the ru…
License
MHassaanButt/MathChallenge
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Have the function MathChallenge(str) take the str parameter being passed and evaluate the mathematical expression within in. For example, if str were "2+(3-1)*3" the output should be 8. Another example: if str were "(2-0)(6/2)" the output should be 6. There can be parenthesis within the string so you must evaluate it properly according to the ru…
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published