Posts

Showing posts from December, 2024

C++ Credit Card Validator

Image
 Continuing my (almost) daily C++ practice, I am now making a program to check if a credit number is valid or not. The first step was to use the Luhn algorithm, researching this, I learned it was a simple and effective fraud protection algorithm.  I broke in down into a few simple steps using this formula and got some test credit card numbers online and attempted the math. It took a little while to get used to, but I got used to it quickly enough. Naturally doing the math is tedious, so I took to Visual Studio 2022 and booted up a C++ file. At first, I created some functions to use later. These were for getting the digits and the sum of the odd and even numbers. Then I created some declarations for each of the functions. I then added some functionality to the main code, mainly prompting the user to input their number and allowing them to do so. Then as a result, adding the sum of the odd and even digits together. For the sum of the even digits, I created a for loop and as I wa...

ATM Cash Machine in C++

Image
The best part of being a game dev to me is...well, making games. So much can be done without touching a line of code, which is great. Well, not really. Recently, I have made sure to implement more code (C++ and C#) into my projects but I feel like I'm neglecting my programming. So I decided to boot up some exercises and test myself with creating a cash machine/ATM interaction system in C++. The first step was to set up the functions and then define the variables. I then created the UI and printed out what would be the interface and then allowed the user to input their choice. I wrapped that in a do while loop and created switch cases for each choice presented in the UI. I then initialised the functions for later use.  Then the output presents the user with the choices for input. (Yes every option is 1 in the UI for now, don't worry I catch that error later!) If the user presses 4, they will exit the interaction. To show the balance, I printed out the balance and added a setpre...