Recently starting to learn programming, I'm looking to move to making larger projects and am just picking up the basics now. I have a feeling this code sort of missed the point? Am looking for feedback for better/ more efficient practices to make it more functional/clean.
The following was the prompt:
1. Simple ATM Software This simple project will essentially create a simulation of an ATM within a Windows program. Just like an ATM, the program should have at least the following features:
- Checking whether an input – such as an ATM card (a debit/credit card number) – is recorded correctly
- Verifying the user by asking for a PIN
- In case of negative verification, logging out the user
- In case of positive verification, showing multiple options, including cash availability, the previous five transactions, and cash withdrawal
- Giving the user the ability to withdraw up to $1,000 worth of cash in one transaction, with total transactions limited to ten per day. (I omitted the total of ten transactions)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ATM_SOFTWARE
{
internal class Program
{
static void Main(string[] args)
{
//Check for a valid ATM input
int cardNumber;
Boolean validCard = false;
while (validCard == false)
{
Console.WriteLine("");
Console.WriteLine("!!INPUT YOUR SIX DIGIT ACCOUNT NUMBER!!");
string digits = Console.ReadLine();
cardNumber = digits.Length;
if (cardNumber == 6)
{
Console.WriteLine("");
Console.WriteLine("!!VALID ACCOUNT NUMBER!!");
validCard = true;
}
else
{
Console.WriteLine("");
Console.WriteLine("!!INVALID ACCOUNT NUMBER. PLEASE TRY AGAIN!!");
validCard = false;
}
}
//Verify the user by asking for a pin
int PIN;
Boolean validPin = false;
while (validPin == false)
{
Console.WriteLine("");
Console.WriteLine("PLEASE ENTER YOUR 4 DIGIT PIN.");
string passCode = Console.ReadLine();
PIN = passCode.Length;
if (PIN == 4)
{
//Result from Positive (Transaction Options)
Console.WriteLine("");
Console.WriteLine("!!VALID PIN NUMBER. WELCOME USER!!");
validPin = true;
}
else
{
//or Negative (Log them out) verification
Console.WriteLine("");
Console.WriteLine("!!INVALID PIN NUMBER. MALICIOUS ACTIVITY DETECTED. TERMINATING USER!!");
validPin = false;
for (int i = 0; i < 5; i++)
{
Console.WriteLine("");
Console.WriteLine("!!DEATH! DEATH! DEATH!!");
}
Console.ReadKey();
System.Environment.Exit(1);
break;
}
}
//Withdrawal options, up to $1000 in one transaction, ten per day
Boolean status = true;
int balance = 1000;
while (status == true)
{
int selection;
Console.WriteLine("");
Console.WriteLine("-----------------------");
Console.WriteLine("");
Console.WriteLine("!!WELCOME THEN, MEAT. EXHANGE YOUR FRIVOLOUS CURRENCY. CHOOSE YOUR OPTION!!");
Console.WriteLine("!!CURRENT BALANCE " + (balance) + " EURODOLLARS!!");
Console.WriteLine("");
Console.WriteLine("-----------------------");
Console.WriteLine("");
Console.WriteLine("!!OPTION 1: WITHDRAW!!");
Console.WriteLine("!!OPTION 2: DEPOSIT!!");
Console.WriteLine("!!OPTION 3: TERMINATE APPLICATION!!");
selection = Convert.ToInt32(Console.ReadLine());
switch (selection)
{
case 1:
Console.WriteLine("");
Console.WriteLine("-----------------------");
Console.WriteLine("");
Console.WriteLine("!!CURRENT BALANCE " + (balance) + " EURODOLLARS!!");
Console.WriteLine("");
Console.WriteLine("!!HOW MUCH DO YOU WANT TO WITHDRAW!!");
int withdraw;
withdraw = Convert.ToInt32(Console.ReadLine());
if (withdraw <= balance)
{
balance -= withdraw;
Console.WriteLine("");
Console.WriteLine("!!DISPENSING CURRENCY!!");
Console.WriteLine("");
Console.WriteLine("-----------------------");
Console.WriteLine("");
Console.WriteLine("!!CURRENT BALANCE " + (balance) + " EURODOLLARS!!");
Console.WriteLine("!!PRESS ANY KEY TO RETURN!!");
Console.ReadKey();
break;
}
else
{
Console.WriteLine("");
Console.WriteLine("!!NICE TRY MEAT, YOU DON'T HAVE THAT MUCH!!");
Console.WriteLine("!!PRESS ANY KEY TO RETURN!!");
Console.ReadKey();
break;
}
case 2:
Console.WriteLine("");
Console.WriteLine("-----------------------");
Console.WriteLine("");
Console.WriteLine("!!CURRENT BALANCE " + (balance) + " EURODOLLARS!!");
Console.WriteLine("");
Console.WriteLine("!!HOW MUCH DO YOU WANT TO DEPOSIT!!");
int deposit;
deposit = Convert.ToInt32(Console.ReadLine());
balance += deposit;
Console.WriteLine("");
Console.WriteLine("!!CURRENT BALANCE " + (balance) + " EURODOLLARS!!");
Console.WriteLine("!!PRESS ANY KEY TO RETURN!!");
Console.ReadKey();
break;
case 3:
Console.WriteLine("");
Console.WriteLine("!!THANK YOU. PRESS ANY KEY TO CLOSE THE APPLICATION!!");
Console.ReadKey();
status = false;
break;
default:
Console.WriteLine("");
Console.WriteLine("!!INVALID SELECTION, TRY AGAIN!!");
Console.ReadKey();
break;
}
}
}
}
}
Main
into smaller manageable functions? \$\endgroup\$