26 votes
Accepted

Validating Credit Card Numbers

First of all, you should encapsulate your functionality in a function, unless you really want to use your code only once. At the moment you would have to duplicate your code somewhat just to check a ...
Zeta's user avatar
  • 19.3k
20 votes
Accepted

Financial website scraper

Here a few suggestions (in no particular order) for improvements on your code: Make variables have locality The line: items = 1 is at the top of the method, ...
Stephen Rauch's user avatar
16 votes
Accepted

Selecting an enum for a payment transaction

You're using the wrong tool for the job. If there's ever going to be a loan that I will pay an amount to every week for 2 years, you're gonna have to write a script to generate the code for you, ...
Pimgd's user avatar
  • 22.3k
16 votes
Accepted

Basic Python OO bank account

Python doesn't have private anything but we still have a need to separate inners of a class from the public interface. By convention, attributes or methods whose name starts with a single underscore ...
301_Moved_Permanently's user avatar
16 votes

Financial website scraper

In addition to what @StephenRauch wrote in his excellent answer, let me add one more comment: Your class is completely useless. Not its functionality, which is fine, but it being a ...
Graipher's user avatar
  • 40.9k
14 votes

Basic Python OO bank account

In this answer I'm not going to review your code, but instead discuss the design of a book-keeping system. (I know that you're just using a bank account as an exercise, but an important part of ...
Gareth Rees's user avatar
  • 49.6k
12 votes

Safely convert dollars to cents

I don't like the 3 argument return you're doing. You're using status and msg to actually do the same thing. They both return a ...
SuperBiasedMan's user avatar
12 votes

Validating Credit Card Numbers

You can do most of this with regex. Going through your requirements: It must only consist of digits (0-9). And so we can use [0-9] for each digit. It must ...
Peilonrayz's user avatar
  • 43.3k
11 votes
Accepted

Simple budget program

Here are the few things I've noticed after a first glance on the program: import os is not used, you can remove it () after the ...
alecxe's user avatar
  • 17.3k
9 votes
Accepted

How to use PHP Visibility method?

Yes, the original code is awful. It is 200 lines of spaghetti code; I have no idea what it does, it is impossible to reuse and extremely difficult to test, debug, or change. That doesn't necessarily ...
tim's user avatar
  • 25.1k
9 votes

Basic Python OO bank account

In Python you can have multiple functions and classes in a single file (module) but is it considered bad practice to do so? You can write as many functions and classes within a Python module as ...
Billal Begueradj's user avatar
8 votes

Basic mortgage calculator

"math.h" should be <cmath>. The brackets are for system libraries whereas the quotes are for user-defined headers. The ....
Jamal's user avatar
  • 34.8k
8 votes
Accepted

Convert an amount to Indian Notation

1. Style guides leave two empty lines before each function (when you're not inside of a class) Python is not C; don't use ; put a space before and after operands. <...
Grajdeanu Alex's user avatar
8 votes

Financial website scraper

You should also split the code in functional parts, and not mix the IO (print(...)) with generating the result base_url First you generate the base_url ...
Maarten Fabré's user avatar
8 votes

Bank Management System

I see a number of things that may help you improve your program. Use the required #includes The code uses std::find which ...
Edward's user avatar
  • 66.4k
7 votes

Bitcoin trading system

In these screening situations, you only get a few seconds to make a good first impression. Unfortunately, this line already makes a bad impression: ...
200_success's user avatar
7 votes

For a given balance and an annual interest rate, calculate the minimum fixed monthly payment to pay off debt in a year

This is a problem that can be solved exactly with a little math, so there should be no need to program a search. Suppose that we borrow initial capital \$c\$ at a monthly interest rate \$r\$, paying ...
Gareth Rees's user avatar
  • 49.6k
7 votes

Validating Credit Card Numbers

Your val_rep function can also be simplified with regular expressions by using backreferences (see the \number syntax). Here <...
User789's user avatar
  • 71
6 votes

Basic mortgage calculator

Two things I noticed: It's a good idea to give your variables meaningful names. On a small project this won't be a problem. On a large project when you have hundreds or even thousands of lines of ...
Conduit's user avatar
  • 203
6 votes

Selecting an enum for a payment transaction

There is a better way indeed, which is to have the installments value as an attribute of each enumeration value. An as example, we can simply consider 2 of those ...
Tunaki's user avatar
  • 9,243
6 votes
Accepted

For a given balance and an annual interest rate, calculate the minimum fixed monthly payment to pay off debt in a year

General comments use a consistent style: space after a comma, or not; spaces around operators, or not; even two spaces sometimes. Python has an official style guide called PEP 8 which is worth a read,...
301_Moved_Permanently's user avatar
6 votes

Banking application for practice

It's not clear what TransactionReport is, but your class creates one and then doesn't do anything to or with it. If the report is modified through public ...
Scott Hannen's user avatar
6 votes

Banking application for practice

You already have a good answer from Scott (I'll add that I've never mocked anything in my life, but DependancyInversion and Injection are valuable design tools even when you ignore testing (which I am ...
VisualMelon's user avatar
  • 7,431
5 votes

Calculating the interest on a series of loans

Do not represent monetary amounts as a decimal type; use an integer type instead. Try to avoid the use of using namespace std. You could still allow the user to ...
Jamal's user avatar
  • 34.8k
5 votes
Accepted

IRS Tax Calculator in Java

You are right, you over-complicated the code. My comments on it: Avoid using static state (here's a good explanation on why). Reuse code. If you start seeing that ...
MiguelAraCo's user avatar
5 votes
Accepted

App that calculates interest into a monthly payment

My honest opinion would be to make an interest calculator class, but we can work on a single function. If you do not already have some input validation elsewhere, I would consider the use of Double....
Chandler Turner's user avatar
5 votes

Validating Credit Card Numbers

You can massively simplify this by using regular expressions. Python includes an efficient module for that, named re (short for regular expressions). In this case, ...
Daniel's user avatar
  • 4,490
5 votes

Simple budget program

The while not x: loop can be replaced with a while True loop and you can break out of it using ...
Ashwini Chaudhary's user avatar
5 votes

Simple budget program

DRY and Data Structures Income and expenses are the same thing, just with different signs. You can cut about half your code by more fully leveraging this. Currently, each of the two have a list of ...
BenC's user avatar
  • 2,738
5 votes
Accepted

Bank ATM machine in Ruby

This is my first review, so please bear with me. I'll start with atm.rb: ...
thesecretmaster's user avatar

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