├── .idea └── .gitignore ├── out └── production │ └── AtmMachineProject │ └── com │ └── sjprogramming │ └── MainClass.class └── src └── com └── sjprogramming ├── ATM.java ├── AtmOperationImpl.java ├── AtmOperationInterf.java └── MainClass.java /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /out/production/AtmMachineProject/com/sjprogramming/MainClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjprogramming/ATM-Machine-Project-Java/737ab6405a05b58038d6eca9c5740b8925aa2677/out/production/AtmMachineProject/com/sjprogramming/MainClass.class -------------------------------------------------------------------------------- /src/com/sjprogramming/ATM.java: -------------------------------------------------------------------------------- 1 | package com.sjprogramming; 2 | 3 | public class ATM { 4 | private double balance; 5 | private double depositAmount; 6 | private double withdrawAmount; 7 | 8 | //default constructor 9 | public ATM(){ 10 | 11 | } 12 | 13 | //getter setter 14 | public double getBalance() { 15 | return balance; 16 | } 17 | 18 | public void setBalance(double balance) { 19 | this.balance = balance; 20 | } 21 | 22 | public double getDepositAmount() { 23 | return depositAmount; 24 | } 25 | 26 | public void setDepositAmount(double depositAmount) { 27 | this.depositAmount = depositAmount; 28 | } 29 | 30 | public double getWithdrawAmount() { 31 | return withdrawAmount; 32 | } 33 | 34 | public void setWithdrawAmount(double withdrawAmount) { 35 | this.withdrawAmount = withdrawAmount; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/sjprogramming/AtmOperationImpl.java: -------------------------------------------------------------------------------- 1 | package com.sjprogramming; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class AtmOperationImpl implements AtmOperationInterf{ 7 | ATM atm=new ATM(); 8 | Map ministmt=new HashMap<>(); 9 | @Override 10 | public void viewBalance() { 11 | System.out.println("Available Balance is : "+atm.getBalance()); 12 | 13 | } 14 | 15 | @Override 16 | public void withdrawAmount(double withdrawAmount) { 17 | if(withdrawAmount%500==0) { 18 | if (withdrawAmount <= atm.getBalance()) { 19 | ministmt.put(withdrawAmount, " Amount Withdrawn"); 20 | System.out.println("Collect the Cash " + withdrawAmount); 21 | atm.setBalance(atm.getBalance() - withdrawAmount); 22 | viewBalance(); 23 | } else { 24 | System.out.println("Insufficient Balance !!"); 25 | } 26 | } 27 | else { 28 | System.out.println("Please enter the amount in multipal of 500"); 29 | } 30 | 31 | } 32 | 33 | @Override 34 | public void depositAmount(double depositAmount) { 35 | ministmt.put(depositAmount," Amount Deposited"); 36 | System.out.println(depositAmount+" Deposited Successfully !!"); 37 | atm.setBalance(atm.getBalance()+depositAmount); 38 | viewBalance(); 39 | 40 | } 41 | 42 | @Override 43 | public void viewMiniStatement() { 44 | for(Map.Entry m:ministmt.entrySet()){ 45 | System.out.println(m.getKey()+""+m.getValue()); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/com/sjprogramming/AtmOperationInterf.java: -------------------------------------------------------------------------------- 1 | package com.sjprogramming; 2 | 3 | public interface AtmOperationInterf { 4 | public void viewBalance(); 5 | public void withdrawAmount(double withdrawAmount); 6 | public void depositAmount(double depositAmount ); 7 | public void viewMiniStatement(); 8 | } 9 | -------------------------------------------------------------------------------- /src/com/sjprogramming/MainClass.java: -------------------------------------------------------------------------------- 1 | package com.sjprogramming; 2 | 3 | import java.util.Scanner; 4 | 5 | public class MainClass { 6 | public static void main(String[] args) { 7 | AtmOperationInterf op=new AtmOperationImpl(); 8 | int atmnumber=12345; 9 | int atmpin=123; 10 | Scanner in=new Scanner(System.in); 11 | System.out.println("Welcome to ATM Machine !!!"); 12 | System.out.print("Enter Atm Number : "); 13 | int atmNumber=in.nextInt(); 14 | System.out.print("Enter Pin: "); 15 | int pin=in.nextInt(); 16 | if((atmnumber==atmNumber)&&(atmpin==pin)){ 17 | while(true){ 18 | System.out.println("1.View Available Balance\n2.Withdraw Amount\n3.Deposit Amount\n4.View Ministatement\n5.Exit"); 19 | System.out.println("Enter Choice : "); 20 | int ch=in.nextInt(); 21 | if(ch==1){ 22 | op.viewBalance(); 23 | 24 | } 25 | else if(ch==2){ 26 | System.out.println("Enter amount to withdraw "); 27 | double withdrawAmount=in.nextDouble(); 28 | op.withdrawAmount(withdrawAmount); 29 | 30 | } 31 | else if(ch==3){ 32 | System.out.println("Enter Amount to Deposit :"); 33 | double depositAmount=in.nextDouble();//5000 34 | op.depositAmount(depositAmount); 35 | 36 | 37 | } 38 | else if(ch==4){ 39 | op.viewMiniStatement(); 40 | 41 | } 42 | else if(ch==5){ 43 | System.out.println("Collect your ATM Card\n Thank you for using ATM Machine!!"); 44 | System.exit(0); 45 | } 46 | else 47 | { 48 | System.out.println("Please enter correct choice"); 49 | } 50 | } 51 | } 52 | else{ 53 | System.out.println("Incorrect Atm Number or pin"); 54 | System.exit(0); 55 | } 56 | 57 | 58 | } 59 | } 60 | --------------------------------------------------------------------------------