Hot answers tagged

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.2k
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
15 votes
Accepted

Stock control system

Start using New IO The java.io packages have been replaced for a reason. They don't integrate well into what the language tries to become and are at best unwieldy. ...
Vogel612's user avatar
  • 25.2k
14 votes
Accepted

Operations to a bank account

Account Structure Since it looks like you are trying to model the bank account slightly more realistically than a typical getting started tutorial, I'd like to address the conceptual structure of ...
Rotem's user avatar
  • 683
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
13 votes

Money class with overloaded operators

This is way too complicated. You could have just the cents as a member and have some helper functions that converts it to the respective parts. This will simplify ...
MAG's user avatar
  • 2,954
12 votes
Accepted

SalesTax problem (C# version)

A couple of small suggestions. Var: You spend a lot of time redeclaring variable types when they are already well established by your code. For example: ...
BlindGarret's user avatar
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
  • 42.7k
11 votes

Stock control system

Firstly, I'm not familiar with the JavaFX nor PostgreSQL technologies, so my comments will be aimed more at Java-specific code practices. See also the answers by Vogel612 and Antot. Use "try-with-...
itchimus's user avatar
  • 111
11 votes
Accepted

Enumerate list with filter criteria

I will assume that the CreditCard class is set in stone, otherwise I probably would store a DateTime in it and calculate ...
AndreySarafanov's user avatar
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.2k
10 votes

Stock control system

I totally agree with Vogel612's observations. Since there is a lot of code for this review, I'd like to add a couple of items. DatabaseAdapter Class In ...
Antot's user avatar
  • 3,637
10 votes

Operations to a bank account

Don't catch NullReferenceException, this is a programming exception, it shouldn't happen when to code is running if you're doing ...
IEatBagels's user avatar
  • 12.4k
10 votes

Operations to a bank account

You have some noise in your code: string iban = Console.ReadLine(); return iban; and ...
Caridorc's user avatar
  • 27.4k
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.9k
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
  • 65.3k
7 votes
Accepted

Calculating the daily profit of a clinic

Break your code into methods if a code line in one method is more than 30 characters: ...
Paritosh's user avatar
  • 2,638
7 votes

Credit Calculator

Loop logic There's definitely something strange going on with your looping. Why do you have so many checks on accnum equalling zero? Why do you ask for account ...
Ben Aaronson's user avatar
  • 5,734
7 votes
Accepted

Bank account model implementation in Django

In general this seems fine, easy to read, you seem to be following PEP8, that's excellent. At first look, this repeated logic in balance and ...
janos's user avatar
  • 111k
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

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