0% found this document useful (0 votes)
56 views

Atm Machine

This document contains code for an ATM machine Java application that allows users to perform basic transactions such as withdrawing and depositing cash. The application initializes starting balances, prompts the user to enter their account and PIN numbers, and provides a menu for transactions. It includes methods for depositing funds that increase the total and available balances, as well as withdrawing funds that performs a check for insufficient funds before decreasing the balances.

Uploaded by

aula_msupa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Atm Machine

This document contains code for an ATM machine Java application that allows users to perform basic transactions such as withdrawing and depositing cash. The application initializes starting balances, prompts the user to enter their account and PIN numbers, and provides a menu for transactions. It includes methods for depositing funds that increase the total and available balances, as well as withdrawing funds that performs a check for insufficient funds before decreasing the balances.

Uploaded by

aula_msupa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

/** atm machine that performs basic transactions */ import java.util.

Scanner;

public class AtmMachine { private double availableBal =80; private double totalBal =100; Scanner input = new Scanner(System.in); public class userAccount { public int userAccount() { System.out.println("Welcome!!! "); System.out.print("Enter your account number: "); int account; account = input.nextInt();

return account; }

/*public int userPin() {

System.out.print("Enter your pin number: "); int pin; pin =input.nextInt();

return pin; } */

public void startAtm() { userAccount account = new userAccount(); account.userAccount();

userPin pin = new userPin(); pin.userPin(); deposit mydeposit = new deposit(); mydeposit.deposit();

withdrawfunds mywithdraw =new withdrawfunds(); mywithdraw.withdrawal();

/* public void showMainMenu() { int selection;

System.out.println("\nATM main menu:"); System.out.println("1 - View account balance"); System.out.println("2 - Withdraw Cash"); System.out.println("3 - Deposit funds"); System.out.println("4 - Exit"); System.out.print("Choice: "); selection =input.nextInt();

switch(selection) { case 1: viewAccountInfo(); break; case 2: withdraw(); break; case 3: addFunds(); break; case 4:

System.out.println("Thank you for using this ATM!!! goodbye"); } }* /* public void viewAccountInfo() { System.out.println("Account Information:"); System.out.println("\t--Total balance: $"+totalBal); System.out.println("\t--Available balance: $"+availableBal); drawMainMenu(); }

public void deposit() { System.out.println("\n***Please insert your money now...***"); totalBal =totalBal +depAmount; availableBal =availableBal +depAmount; }

public void checkNsf() { if(totalBal -withdrawAmount < 0) System.out.println("\n***ERROR!!! Insufficient funds in you accout***"); else {

totalBal =totalBal -withdrawAmount; availableBal =availableBal -withdrawAmount; System.out.println("\n***Please take your money now...***"); } }

public void addFunds() { int addSelection;

System.out.println("Deposit funds:"); System.out.println("1 - $20"); System.out.println("2 - $40"); System.out.println("3 - $60"); System.out.println("4 - $100"); System.out.println("5 - $200"); System.out.print("Cancel Transaction: "); System.out.print("Choice: "); addSelection =input.nextInt();

switch(addSelection) { case 1: deposit(20); drawMainMenu();

break; case 2: deposit(40); drawMainMenu(); break; case 3: deposit(60); drawMainMenu(); break; case 4: deposit(100); drawMainMenu(); break; case 5: drawMainMenu(); break; } }

public void withdraw() { int withdrawSelection;

System.out.println("Withdraw money:"); System.out.println("1 - $20");

System.out.println("2 - $40"); System.out.println("3 - $60"); System.out.println("4 - $100"); System.out.println("5 - Back to main menu"); System.out.print("Choice: "); withdrawSelection =input.nextInt();

switch(withdrawSelection) { case 1: checkNsf(20); drawMainMenu(); break; case 2: checkNsf(40); drawMainMenu(); break; case 3: checkNsf(60); drawMainMenu(); break; case 4: checkNsf(100); drawMainMenu(); break;

case 5: drawMainMenu(); break; } } */ public static void main(String args[]) { AtmMachine myAtm = new AtmMachine(); myAtm.startAtm(); } } }

You might also like