KEMBAR78
Java Atm Ptoject | PDF | Automated Teller Machine | Class (Computer Programming)
0% found this document useful (0 votes)
158 views10 pages

Java Atm Ptoject

This document provides details about a Java ATM project that simulates basic ATM functionality. There are three main classes - Account, ATM, and ChoiceMenu. The Account class contains methods for depositing, withdrawing, and checking balances. The ATM class acts as the main driver. The ChoiceMenu class handles user login and provides an interactive menu for users to select account type and perform transactions. Key functionality includes withdrawing and depositing cash, checking balances for different account types, and validating user login with customer number and PIN.

Uploaded by

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

Java Atm Ptoject

This document provides details about a Java ATM project that simulates basic ATM functionality. There are three main classes - Account, ATM, and ChoiceMenu. The Account class contains methods for depositing, withdrawing, and checking balances. The ATM class acts as the main driver. The ChoiceMenu class handles user login and provides an interactive menu for users to select account type and perform transactions. Key functionality includes withdrawing and depositing cash, checking balances for different account types, and validating user login with customer number and PIN.

Uploaded by

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

Date-15-May-2023

Java ATM Project


The ATM (Automated Teller Machine) project in Java is the short implementation of ATM
functionality using Java.

Introduction:-
Java ATM Project is developed using Java language OOPs Concept like inheritance. In this
project, I have implemented some basic functionality of an ATM using Java like an
ATM(AUtomated Teller Machine) providing us the functionality of withdrawing cash, from a
savings account or checking account, etc. In this ATM project, we can also deposit the cash, and
based on our cash in the machine, we can withdraw it. Users can use ATMs by using the correct
Customer Number and PIN.

The functionality of this Project:-


In this project users have the following functionality:-

1. User has the option to use the savings account or current account based on his/her choice.

2. Users can withdraw money by entering the correct amount.

3. Users can deposit money in both account types.

4. Users can check the left balance from both accounts after withdrawing.

5. Users can choose any choice based on his/her requirements.

6. Provide or implement the idea of Java inheritance which can help others to learn Java
inheritance topics.

Java Classes Used:-


In this project, there are three classes ATM.java, Account.java, ChoiceMenu.java.

ATM class:-

This is the main class. And it extends ChoiceMenu.java class. In this class, we have created the
object of ChoiceMenu class and using this object we call the login method of this class to log in
the user in the ATM by using CustomerNumber and PinNumber.

Account class:-
This is our account class in this class we have implemented methods like setCustomrPin, set
customer number, etc. This class implements all the methods used for checking balance, deposit
balance or withdraw balance from both types of accounts CheckingAccount and SavingAccount.

ChoiceMenu class:-
This Java class extends Account.java class and provides user choice to use ATM. It also provides
a Login Method to logged users in so that users can use the ATM, it provides user choices by
using the switch concept in Java. Based on user choice it works or produces the result.

Login or Demo:-
To login or have a demo of this project users must have to use any one of the following
CustomerNumber and their respective PinNumber when asked.

1) Account.java

package ATM;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Account {
Scanner sc=new Scanner(System.in);
DecimalFormat money=new DecimalFormat("'$'###,##0.00");
private int customerNumber;
private int pinNumber;
private double checkingBalance=0;
private double savingBalance=0;

public int setCustomerNumber(int customerNumber)


{
this.customerNumber=customerNumber;
return customerNumber;
}

public int getCustomerNumber()


{
return customerNumber;
}

public int setPinNumber(int pinNumber)


{
this.pinNumber=pinNumber;
return pinNumber;
}

public int getPinNumber()


{
return pinNumber;
}

public double getCheckingBalance()


{
return checkingBalance;
}

public double getSavingBalance()


{
return savingBalance;
}

public double calcCheckingWithdraw(double amount)


{
checkingBalance=(checkingBalance-amount);
return checkingBalance;
}

public double calcSavingWithdraw(double amount)


{
savingBalance=(savingBalance-amount);
return savingBalance;
}

public double calcCheckingDeposit(double amount)


{
checkingBalance=(checkingBalance+amount);
return checkingBalance;
}

public double calcSavingDeposit(double amount)


{
savingBalance=(savingBalance+amount);
return savingBalance;
}

public void getCheckingWithdrawlInput()


{
System.out.println("Checking Account Balance: " +
money.format(checkingBalance));
System.out.println("Amount you want to withdraw from Checking Account: ");
double amount=sc.nextDouble();

if((checkingBalance-amount)>=0)
{
calcCheckingWithdraw(amount);
System.out.println("New Checking Account balance: " +
money.format(checkingBalance) + "\n");

else
{
System.out.println("Balance can't be negative." + "\n");
}
}

public void getSavingWithdrawlInput()


{
System.out.println("Checking Account Balance: " +
money.format(savingBalance));
System.out.println("Amount you want to withdraw from Saving Account: ");
double amount=sc.nextDouble();

if((savingBalance-amount)>=0)
{
calcSavingWithdraw(amount);
System.out.println("New Saving Account balance: " +
money.format(savingBalance) + "\n");

else
{
System.out.println("Balance can't be negative." + "\n");
}
}

public void getCheckingDepositInput()


{
System.out.println("Checking Account Balance: " +
money.format(checkingBalance));
System.out.println("Amount you want to deposit in Checking Account: ");
double amount=sc.nextDouble();

if((checkingBalance+amount)>=0)
{
calcCheckingDeposit(amount);
System.out.println("New Checking Account balance: " +
money.format(checkingBalance) + "\n");

else
{
System.out.println("Balance can't be negative." + "\n");
}
}

public void getSavingDepositInput()


{
System.out.println("Checking Account Balance: " +
money.format(savingBalance));
System.out.println("Amount you want to deposit in Saving Account: ");
double amount=sc.nextDouble();

if((savingBalance+amount)>=0)
{
calcSavingDeposit(amount);
System.out.println("New Saving Account balance: " +
money.format(savingBalance) + "\n");

else
{
System.out.println("Balance can't be negative." + "\n");
}
}

2) ATM.java

package ATM;

import java.io.IOException;
public class ATM extends ChoiceMenu{
public static void main(String args[]) throws IOException
{

ChoiceMenu choice=new ChoiceMenu();


choice.getLogin();
}

3) ChoiceMenu.java

package ATM;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class ChoiceMenu extends Account {


Scanner menuInput=new Scanner(System.in);
DecimalFormat money=new DecimalFormat("'$'###,##0.00");

HashMap<Integer, Integer> data=new HashMap<Integer, Integer>();

//Validate login information customer number and pin number

public void getLogin() throws IOException


{
int x=1;
do
{
try
{
/*
* Accounts in a HashMap form, key = customer number, value =
pin
* number
*/

data.put(123123123, 12345);
data.put(123412345, 1236);

System.out.println("Welcome to the ATM Project!");

System.out.println("Enter your Customer Number: ");


setCustomerNumber(menuInput.nextInt());
System.out.println("Enter your pin: ");
setPinNumber(menuInput.nextInt());
}
catch(Exception e)
{
System.out.println("\n" + "Inavlid character(s). Only numbers." +
"\n");
x=2;
}
//loop for checking customerNumber and pinNumber
for(Entry<Integer,Integer> entry:data.entrySet())
{
if(entry.getKey()==getCustomerNumber() &&
entry.getValue()==getPinNumber())
{
getAccountType();
}
}
System.out.println("\n" + "Wrong Customer Number or Pin Number." +
"\n");

}while(x==1);
}

//Account type menu with selection

public void getAccountType()


{
System.out.println("Select the Account you want to access: ");
System.out.println("Type 1- Checking Account");
System.out.println("Type 2- Saving Account");
System.out.println("Type 3- Exit");
System.out.println("Choice: ");

selection=menuInput.nextInt();

switch(selection)
{
case 1:
getChecking();
break;

case 2:
getSaving();
break;
case 3:
System.out.println("Thank You for using this ATM: ");
break;

default:
System.out.println("\n" + "Inavlid Choice. " + "\n");
getAccountType();
}
}

//Display Checking Account Menu with Selections

public void getChecking()


{
System.out.println("Checking Account: ");
System.out.println("Type 1- View Balance");
System.out.println("Type 2- Withdraw Money");
System.out.println("Type 3- Deposit Money");
System.out.println("Type 4- Exit");
System.out.println("Choice: ");

selection=menuInput.nextInt();

switch(selection)
{
case 1:
System.out.println("Checking Account Balance: " +
money.format(getCheckingBalance()) + "\n");
getAccountType();
break;

case 2:
getCheckingWithdrawlInput();
getAccountType();
break;

case 3:
getCheckingDepositInput();
getAccountType();
break;

case 4:
System.out.println("Thank You for using this ATM. ");
break;
default:
System.out.println("\n" + "Invalid choice." + "\n");
getChecking();
}
}

//Display saving account menu with selection

public void getSaving()


{
System.out.println("Saving Account: ");
System.out.println("Type 1- View Balance");
System.out.println("Type 2- Withdraw Money");
System.out.println("Type 3- Deposit Money");
System.out.println("Type 4- Exit");
System.out.println("Choice: ");

selection=menuInput.nextInt();

switch(selection)
{
case 1:
System.out.println("Saving Account Balance: " +
money.format(getSavingBalance()) + "\n");
getAccountType();
break;

case 2:
getSavingWithdrawlInput();
getAccountType();
break;

case 3:
getSavingDepositInput();
getAccountType();
break;

case 4:
System.out.println("Thank You for using this ATM. ");
break;

default:
System.out.println("\n" + "Invalid choice." + "\n");
getSaving();
}
}
int selection;

You might also like