You are on page 1of 8

import java.util.

Random;
import java.util.Scanner;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this
template
*/

/**
*
* @author Administrator
*/
public class Simple_Banking_System {
public static void main(String[] args){

//Important Variables
boolean access = false;
String input;
boolean looper = true;
Random rand = new Random();
Scanner x = new Scanner(System.in);

//Banking User Information (Admin) initialized user;


String accountName = "Admin";
int PinNumber = 1111;
double Balance = 1_000_000;
int AccountNumber = 111111;

//Start of Simple Banking System


while (looper == true){
System.out.println("Welcome to Simple Banking System!");
System.out.println("Are you a new depositor or an existing
depositor?");
System.out.println("Type \"0\" for 'New Depositor' if you're a new
depositor or");
System.out.println("Type \"1\" for 'Existing Depositor' if you're an
existing depositor");
System.out.println("Type \"2\" for 'Exit Program' to end program");
System.out.print("Input Here: ");
x.nextLine();
input = x.nextLine();
//System.out.println("------------------------------");

//New Depositor
// <editor-fold>
if (input.equals("0")) {
System.out.println("Please fill the following:");
System.out.print("Account Name: ");
accountName = x.nextLine();
System.out.print("Pin Number: ");
PinNumber = x.nextInt();
System.out.print("Initial Deposit Amount: ");
Balance = x.nextInt();
AccountNumber = rand.nextInt(100000,999999);
System.out.println("You're Account has been made here is your Account
Number: " + AccountNumber);
System.out.println("------------------------------");
// </editor-fold>

// Login
// <editor-fold>
while (access == false){
System.out.println("Please enter the following:");
System.out.print("Account Number: ");
int LoginNumber = x.nextInt();
System.out.print("Pin Number: ");
int LoginPin = x.nextInt();
if(LoginNumber == AccountNumber && LoginPin == PinNumber){
System.out.println("Login Succesful");
access = true;
}else{
System.out.println("Wrong Account Number or Account Pin");
access =false;
}
}
// </editor-fold>

//Main Interface
// <editor-fold>
while(access == true){
System.out.println("------------------------------");
System.out.println("Welcome Back " + 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 UI = x.nextInt();
System.out.println("------------------------------");
switch (UI) {
case 0 -> { //Withdrawal Module
System.out.println("------------------------------");
System.out.print("Withdraw Amount: ");
double WA = x.nextInt();
if (WA < 10000 && WA < Balance) {
System.out.println("Transaction Completed");
Balance -= WA;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
}
case 1 -> { // Deposit Module
System.out.println("------------------------------");
System.out.print("Deposit Amount: ");
double AD = x.nextInt();
Balance += AD;
System.out.println("Balance: " + Balance);
}
case 2 -> { // Pay Bills Module
System.out.println("------------------------------");
System.out.println("Choose the Utility 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 = x.nextInt();
switch (TBP) {
case 0:
System.out.println("------------------------------");
System.out.println("Electricity");
System.out.print("Amount to be Paid: ");
double AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
break;
case 1:
System.out.println("------------------------------");
System.out.println("Water Utilities");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
} else {
System.out.println("Transaction Failed");
}
break;
case 2:
System.out.println("------------------------------");
System.out.println("Cable/Internet");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
break;
case 3:
System.out.println("------------------------------");
System.out.println("Loans");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
System.out.println("Processing ...");
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
System.out.println();
}
break;
default:
System.out.println("------------------------------");
System.out.println("Invalid Input");
System.out.println();
}
}
case 3 -> { // Transfer Funds
System.out.println("------------------------------");
System.out.print("Account Number: ");
int TA = x.nextInt();
System.out.print("Amount to be transferred: ");
double AT = x.nextInt();
if (AT < Balance) {
System.out.println("Transaction Complete");
Balance -= AT;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
System.out.println();
}
}
case 4 -> { // Change Pin
System.out.println("------------------------------");
System.out.println("Please fill the following: ");
System.out.print("Account Number: ");
int AN = x.nextInt();
System.out.print("Old PIN Number: ");
int PIN = x.nextInt();
System.out.print("New PIN: ");
int NPN = x.nextInt();
if (AN == AccountNumber && PIN == PinNumber) {
PinNumber = NPN;
System.out.println("------------------------------");
System.out.println("New Pin Number: " + PinNumber);
System.out.println();
} else {
System.out.println("------------------------------");
System.out.println("Wrong Account Number and/or Pin
Number");
System.out.println();
}
}
case 5 -> { // Logout
System.out.println("------------------------------");
System.out.println("Are you sure you want to log out?");
System.out.println("0 for NO");
System.out.println("1 for YES");
System.out.print("Input here: ");
int y = x.nextInt();
if (y == 0) {
access = true;

} else if (y == 1) {
System.out.println("------------------------------");
System.out.println("Thank you for using Simple Banking
System");
System.out.println("We hope to see you again. Goodbye!");
System.out.println("------------------------------");
access = false;
looper = true;
}
}
default -> {
System.out.println("Invalid Input");
System.out.println("------------------------------");
}
}
}
// </editor-fold>

//Existing Depositor
// <editor-fold>
}else if(input.equals("1")){
while (access == false){
System.out.println("Please enter the following:");
System.out.print("Account Number: ");
int LoginNumber = x.nextInt();
System.out.print("Pin Number: ");
int LoginPin = x.nextInt();
if(LoginNumber == AccountNumber && LoginPin == PinNumber){
System.out.println("Login Succesful");
access = true;
}else{
System.out.println("Wrong Account Number or Account Pin");
access = false;
}
}
//Main Interface
// <editor-fold>
while(access == true){
System.out.println("------------------------------");
System.out.println("Welcome Back " + 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 UI = x.nextInt();
System.out.println("------------------------------");
switch (UI) {
case 0 -> { //Withdrawal Module
System.out.println("------------------------------");
System.out.print("Withdraw Amount: ");
double WA = x.nextInt();
if (WA < 10000 && WA < Balance) {
System.out.println("Transaction Completed");
Balance -= WA;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
}
case 1 -> { // Deposit Module
System.out.println("------------------------------");
System.out.print("Deposit Amount: ");
double AD = x.nextInt();
Balance += AD;
System.out.println("Balance: " + Balance);
}
case 2 -> { // Pay Bills Module
System.out.println("------------------------------");
System.out.println("Choose the Utility 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 = x.nextInt();
switch (TBP) {
case 0:
System.out.println("------------------------------");
System.out.println("Electricity");
System.out.print("Amount to be Paid: ");
double AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
break;
case 1:
System.out.println("------------------------------");
System.out.println("Water Utilities");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
} else {
System.out.println("Transaction Failed");
}
break;
case 2:
System.out.println("------------------------------");
System.out.println("Cable/Internet");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
}
break;
case 3:
System.out.println("------------------------------");
System.out.println("Loans");
System.out.print("Amount to be Paid: ");
AP = x.nextInt();
System.out.println("Processing ...");
if (AP < Balance) {
System.out.println("Transaction Complete");
Balance -= AP;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
System.out.println();
}
break;
default:
System.out.println("------------------------------");
System.out.println("Invalid Input");
System.out.println();
}
}
case 3 -> { // Transfer Funds
System.out.println("------------------------------");
System.out.print("Account Number: ");
int TA = x.nextInt();
System.out.print("Amount to be transferred: ");
double AT = x.nextInt();
if (AT < Balance) {
System.out.println("Transaction Complete");
Balance -= AT;
System.out.println("Balance: " + Balance);
} else {
System.out.println("Transaction Failed");
System.out.println();
}
}
case 4 -> { // Change Pin
System.out.println("------------------------------");
System.out.println("Please fill the following: ");
System.out.print("Account Number: ");
int AN = x.nextInt();
System.out.print("Old PIN Number: ");
int PIN = x.nextInt();
System.out.print("New PIN: ");
int NPN = x.nextInt();
if (AN == AccountNumber && PIN == PinNumber) {
PinNumber = NPN;
System.out.println("------------------------------");
System.out.println("New Pin Number: " + PinNumber);
System.out.println();
} else {
System.out.println("------------------------------");
System.out.println("Wrong Account Number and/or Pin
Number");
System.out.println();
}
}
case 5 -> { // Logout
System.out.println("------------------------------");
System.out.println("Are you sure you want to log out?");
System.out.println("0 for NO");
System.out.println("1 for YES");
System.out.print("Input here: ");
int y = x.nextInt();
if (y == 0) {
access = true;

} 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("------------------------------");
access = false;
looper = false;
}
}
default -> {
System.out.println("Invalid Input");
System.out.println("------------------------------");
}
}
}
// </editor-fold>
}else if(input.equals("2")){
looper = false;
}

else{
System.out.println("Invalid Input");
}
}

// </editor-fold>
}
}

You might also like