Skip to main content
14 votes
Accepted

Equation Evaluator

In real life, I would use knowledge of existing libraries to pull out an almost-finished solution. In particular, I think it is an example for Boost.Spirit, which is what I would use for a real ...
JDługosz's user avatar
  • 11.4k
11 votes
Accepted

A queue based calculator for basic math operations

I see a number of things that may help you improve your code. Add error checking Data input usually requires a lot of careful consideration for most software. Checking for malformed input and ...
Edward's user avatar
  • 66.5k
10 votes

Validator for mathematical expression in infix form

Don’t write using namespace std;. You can, however, in a CPP file (not H file), or inside a function, put individual ...
JDługosz's user avatar
  • 11.4k
9 votes
Accepted

Shunting-yard algorithm for expression parser

isInteger is not needed. Use std::isdigit. Trust the logic. An else if condition is mutually ...
vnp's user avatar
  • 56.8k
9 votes

Console calculator, takes a string as input (like: 2+3*4-1+3) and outputs the result

Some quick observations: Don't use using namespace std Prefer using \n over std::endl ...
yuri's user avatar
  • 4,458
8 votes
Accepted

Evaluating arithmetic expressions

Spacing I'd like to see some more blank lines. They help separate code into blocks. Without a blank line here and there, the code looks like a wall of text. As someone who answers questions on Stack ...
zondo's user avatar
  • 3,797
8 votes

Python calculator taking string input

On top of the other very good answers: Code organisation and tests It is a good idea to separate the logic about input/output from the logic computing results. In your case, you could have a ...
SylvainD's user avatar
  • 29.2k
8 votes

Calculator using variable names

I think your solution does work, but it's very long-winded. Your IN: and OUT: comments should be moved to docstrings ...
Reinderien's user avatar
  • 62.8k
7 votes
Accepted

Creating truth table from a logical statement

1. Bugs There's an infinite loop in solve: ...
Gareth Rees's user avatar
  • 49.6k
7 votes

Evaluating arithmetic expressions

1. Review The error messages are not very helpful: ...
Gareth Rees's user avatar
  • 49.6k
7 votes
Accepted

Interpret English as Math and Perform Operations

How should I be naming variables? Operation and numInString good names? Great question, Python has an extensive but approachable style guide call PEP8. Specifically local variables should be ...
Zak's user avatar
  • 211
7 votes

Command line calculator in C

General Observations I'm going to address coding style here, since the code is almost unreadable. If you are interested in getting your code reviewed you may want to pay attention to what the ...
pacmaninbw's user avatar
  • 24k
7 votes

Command line calculator in C

Don't write clever code: if (printf("%g\n", b(&(const char *){*argv}, 0)) < 0) You know you’re brilliant, but maybe you’d like to understand what ...
Harith's user avatar
  • 9,452
6 votes

Python calculator taking string input

your english is more than good ;) Very small comments to give some advice at this level: Try a bit better naming for functions, is vital for anyone that will read your code to help understand them. ...
A. Romeu's user avatar
  • 1,065
6 votes

Python calculator taking string input

When you're writing a computer program in any language, one of your goals should be to eliminate duplicated code. Computers are good at doing the same task over and over again, even with slightly ...
Snowbody's user avatar
  • 8,442
6 votes

Expression calculator in Python

Nice job with your calculator. Overall it's pretty clean, and you have decent use of functions to break behaviors up. But, I'm very nit picky and am going to recommend some really aggressive ...
Bailey Parker's user avatar
6 votes

Validator for mathematical expression in infix form

I’ll go over check_expression itself, the meat of your logic, in a separate message. Your other functions are just incidental and you just need to learn what’s ...
JDługosz's user avatar
  • 11.4k
6 votes
Accepted

Console calculator, takes a string as input (like: 2+3*4-1+3) and outputs the result

Don’t write using namespace std;. You can, however, in a CPP file (not H file) or inside a function put individual ...
JDługosz's user avatar
  • 11.4k
6 votes
Accepted

Shunting-yard algorithm

Interface design Note that you only support nonnegative integers as operands. Your algorithm correctly rearranges the input tokens in postfix order, but it would be more useful if it preserved the ...
200_success's user avatar
6 votes
Accepted

Synthetic division calculator

Currently some of your code is very specialized to the exact use case you have. For example, the get_factors function takes the unparsed equation and needs to ...
Graipher's user avatar
  • 41k
6 votes
Accepted

Evaluating arithmetic expressions and plotting graphs

Since you mention that this was originally C++ code, well it shows. First, style. Python has an official style-guide, PEP8. It recommends writing if condition ...
Graipher's user avatar
  • 41k
6 votes
Accepted

Infix to Postfix Converter in C++

std::getline is defined in the include <string>, which you do not have, so the code doesn't compile for me. Don't do ...
pm100's user avatar
  • 791
6 votes

Mathematical expression evaluator (C++)

For a beginner this already quite advanced and well-written code. Improving custom exceptions It's great that you have custom exceptions that derive from ...
G. Sliepen's user avatar
  • 58.7k
5 votes

Console calculator, takes a string as input (like: 2+3*4-1+3) and outputs the result

if (!(v[i - 1] == '*') && !(v[i - 1] == '/')) would read more naturally as: ...
Erik Eidt's user avatar
  • 161
5 votes

Basic arithmetic calculator with float, parentheses and operator priority support

I see a number of things that may help you improve your program. Put each statement on a separate line Instead of crowding things together like this: ...
Edward's user avatar
  • 66.5k
5 votes
Accepted

Basic arithmetic calculator with float, parentheses and operator priority support

Design Calculator class Looking at your Calculator class, you are doing all your work in the constructor, including printing output. The consumers of this class (...
cariehl's user avatar
  • 947
5 votes

Postfix calculator in Java

I didn't go over all the code. Here are my comments so far: Stack The class contains a Scanner for no apparent reason. While it is your implementation, which does ...
Sharon Ben Asher's user avatar
5 votes

Synthetic division calculator

Bugs if part[0] == "-": coeffs.append(int(part[1]) * -1) Nowhere in the restrictions does it say that -x^2...
Peter Taylor's user avatar
  • 24.1k
5 votes
Accepted

JavaRPN calculator

In those lines doing equality checks, you write inputs[i] repeatedly. This has two main problems: It's likely bulkier than necessary If you ever need to change ...
Carcigenicate's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible