0% found this document useful (0 votes)
29 views4 pages

Simple Banking System Prototype

This document contains code for a simple banking system program in Java. It defines classes and methods for user login, account creation, deposits, withdrawals, transfers, bill payments and logout. The program uses object-oriented programming principles to model a basic banking interface and transactions.

Uploaded by

juencyzalty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Simple Banking System Prototype

This document contains code for a simple banking system program in Java. It defines classes and methods for user login, account creation, deposits, withdrawals, transfers, bill payments and logout. The program uses object-oriented programming principles to model a basic banking interface and transactions.

Uploaded by

juencyzalty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

Random;
import java.util.Scanner;

public class Practice{


// Universal Variables
public static class MyVar{
static Scanner x = new Scanner(System.in);
static Random rand = new Random();
static String AccountName = "User0";
static int PinNumber = 0000;
static int Bal = 0;
static int AccountNumber = 000000;
}
static void Intro(){
//Intro
System.out.println("Welcome to Simple Banking System!");
System.out.println("Are you a new depositor or an existing depositor?");
System.out.println("Type 'New Depositor' if you're a new depositor or");
System.out.println("Type 'Existing Depositor' if you're an existing
depositor");
System.out.print("Input Here: ");
String A = MyVar.x.nextLine();
//New Depositor
if (A.equals("New Depositor")) {
System.out.println("Please fill the following:");
System.out.print("Account Name: ");
MyVar.AccountName = MyVar.x.nextLine();
System.out.print("Pin Number: ");
MyVar.PinNumber = MyVar.x.nextInt();
System.out.print("Initial Deposit Amount: ");
MyVar.Bal = MyVar.x.nextInt();
MyVar.AccountNumber = MyVar.rand.nextInt(100000,999999);
System.out.println("You're Account has been made here is your Account
Number: " + MyVar.AccountNumber);
Login();
//Existing Depositor
} else if (A.equals("Existing Depositor")) {
Login();
}
}
// LOGIN
public static void Login(){
System.out.println("Please enter the following:");
System.out.print("Account Number: ");
int LoginNumber = MyVar.x.nextInt();
System.out.print("Pin Number: ");
int LoginPin = MyVar.x.nextInt();
if(LoginNumber == MyVar.AccountNumber && LoginPin == MyVar.PinNumber){
MainMethod();
}else{
Login();
}
}
// Main Interface
static void MainMethod(){
System.out.println("Welcome Back " + MyVar.AccountName);
System.out.println();
System.out.println("What would you like to do?");
System.out.println("0 for Withdraw");
System.out.println("1 for Deposit");
System.out.println("2 for Pay Bills");
System.out.println("3 for Transfer Funds");
System.out.println("4 for Change Pin");
System.out.println("5 for Logout");
System.out.print("Input here: ");
int mainProgram = MyVar.x.nextInt();
switch (mainProgram){
case 0: //Withdrawal Module
System.out.print("Withdraw Amount: ");
int WA = MyVar.x.nextInt();
if (WA < 10000 && WA < MyVar.Bal){
System.out.println("Transaction Completed");
MyVar.Bal -= WA;
System.out.println("Balance: " + MyVar.Bal);
}else{
System.out.println("Transaction Failed");
}
MainMethod();
break;
case 1: // Deposit Module
System.out.print("Deposit Amount: ");
int AD = MyVar.x.nextInt();
MyVar.Bal += AD;
System.out.println("Balance: " + MyVar.Bal);
MainMethod();
break;
case 2: // Pay Bills Module
System.out.println("Choose the Biller that you intend to
pay for in the available Categories");
System.out.println("0 for Electricity");
System.out.println("1 for Water Utilities");
System.out.println("2 for Cable/Internet");
System.out.println("3 for Loans");
System.out.print("Input here: ");
int TBP = MyVar.x.nextInt();
switch (TBP){
case 0:
System.out.println("Electricity");
System.out.print("Amount to be Paid: ");
int AP = MyVar.x.nextInt();
if(AP < MyVar.Bal){
System.out.println("Transaction
Complete");
MyVar.Bal -= AP;
System.out.println("Balance: " +
MyVar.Bal);
}else{
System.out.println("Transaction
Failed");
}break;
case 1:
System.out.println("Water Utilities");
System.out.print("Amount to be Paid: ");
AP = MyVar.x.nextInt();
if(AP < MyVar.Bal){
System.out.println("Transaction
Complete");
MyVar.Bal -= AP;
}else{
System.out.println("Transaction
Failed");
}break;
case 2:
System.out.println("Cable/Internet");
System.out.print("Amount to be Paid: ");
AP = MyVar.x.nextInt();
if(AP < MyVar.Bal){
System.out.println("Transaction Complete");
MyVar.Bal -= AP;
System.out.println("Balance: " +
MyVar.Bal);
}else{
System.out.println("Transaction Failed");
}break;
case 3:
System.out.println("Loans");
System.out.print("Amount to be Paid: ");
AP = MyVar.x.nextInt();
System.out.println("Processing ...");
if(AP < MyVar.Bal){
System.out.println("Transaction Complete");
MyVar.Bal -= AP;
System.out.println("Balance: " +
MyVar.Bal);
}else{
System.out.println("Transaction Failed");
System.out.println();
}break;
default:
System.out.println("Invalid Input");
System.out.println();
}
MainMethod();
break;
case 3: // Transfer Funds
System.out.print("Account Number: ");
int TA = MyVar.x.nextInt();
System.out.print("Amount to be transferred: ");
int AT = MyVar.x.nextInt();
if(AT < MyVar.Bal){
System.out.println("Transaction Complete");
MyVar.Bal -= AT;
System.out.println("Balance: " + MyVar.Bal);
}else{
System.out.println("Transaction Failed");
System.out.println();
}
MainMethod();
break;
case 4: // Change Pin
System.out.println("Please fill the foloowing: ");
System.out.print("Account Number: ");
int AN = MyVar.x.nextInt();
System.out.print("Old PIN Number: ");
int PIN = MyVar.x.nextInt();
System.out.print("New PIN: ");
int NPN = MyVar.x.nextInt();
if(AN == MyVar.AccountNumber && PIN == MyVar.PinNumber)
{
MyVar.PinNumber = NPN;
System.out.println("New Pin Number: " +
MyVar.PinNumber);
System.out.println();
}else{
System.out.println("Wrong Account Number and/or Pin
Number");
System.out.println();
}
MainMethod();
break;
case 5: // Logout
System.out.println("Are you sure you want to log out?");
System.out.println("0 for NO");
System.out.println("1 for YES");
int y = MyVar.x.nextInt();
if(y == 0){
MainMethod();
}else if(y == 1){
System.out.println("Thank you for using Simple
Banking System");
System.out.println("We hope to see you again.
Goodbye!");
System.out.println();
}
break;
default:
System.out.println("Invalid Input");
MainMethod();
}
}
public static void main(String[] args) {
//Simple Banking System
Intro();
}
}

You might also like