code for ATM

code for ATM

View Answers

August 24, 2008 at 8:47 PM

can you plz explain ur requirement

or plz look below url which u give brif idea:

http://studentblock.com/courses/cs-101/atm-source-code-create-the-database/

Thanks

August 25, 2008 at 7:23 PM

Hi friend,

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;

public class ATM extends Applet {
public void init() {
add(new ATMPanel());
}

static class ATMPanel extends Panel {
// setting up a pin that is needed for the atm
private static String PIN= "5803";
int accountmoney = 5000000;
//constants that provide state information for the atm
private static final int WAIT_FOR_CARD = 1;
private static final int WAIT_FOR_PIN = 2;
private static final int MENU_DISPLAYED = 3;
private static final int TRANSFER_MONEY = 4;
private static final int DISBURSE_MONEY = 5;
private static final int CHECK_BALANCE = 6;
private static final int SAVING_ACC = 7;
private TextArea mScreen= new TextArea("", 6, 45, TextArea.SCROLLBARS_NONE);
// some buttons
Button mEnter= new Button("Enter");
Button mClear= new Button("Clear");
Button mCancel= new Button("Cancel");
JButton Receipt = new JButton("Receipts Slot");
Button Quit = new Button("Quit");
JButton Cash = new JButton("Cash Slot");

private JLabel something = new JLabel("Yeah");
private String mPin= "";
private String Transfer= "";
private int Transfer1;
private int state = WAIT_FOR_CARD; // the current state of the ATM

public ATMPanel() {
setLayout(new BorderLayout());
mScreen.setEditable(false);
ActionListener keyPadListener = new ActionListener(){
public void actionPerformed(ActionEvent e){
key(Integer.parseInt(((Button) e.getSource()).getLabel()));
}
};

// create keypad with 10 buttons

JPanel keypad= new JPanel(new GridLayout(0,3));
for(int i=1; i<10; i++) {
Button btn= new Button(String.valueOf(i));
btn.addActionListener(keyPadListener);
keypad.add(btn);
}

keypad.add(new Label());
Button btn= new Button("0");
btn.addActionListener(keyPadListener);
keypad.add(btn);

August 25, 2008 at 7:24 PM

// what to do when the enter button is clicked
mEnter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// call the method enter() when enter is pressed.
enter();
}
});

// see enter() - same idea
mClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clear();
}
});
// same idea as enter()
mCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
cancel();
}
});
// same idea as enter()
Receipt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
receipt();
}
});
// same idea as enter()
Quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
quit();
}
});
// same idea as enter()
Cash.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cash();
}
});

// add enter, clear, receeipt, quit, and cancel buttons to panel

Panel controls= new Panel(new GridLayout(3,2));
controls.add(mEnter);
controls.add(mClear);
controls.add(mCancel);
controls.add(Receipt);
controls.add(Quit);
controls.add(Cash);

add("North", mScreen);
add("Center", keypad);
add("South", controls);

mScreen.setText("Enter your card and press a number key.");
}

August 25, 2008 at 7:24 PM

private void key(int key) {
switch (state) {
case WAIT_FOR_CARD: // waiting for card
clear();
mScreen.setText(
"Card accepted.\n" +
"Welcome to ICICI Bank.\n" +
"Please enter your pin...");
state = WAIT_FOR_PIN;
break;
case WAIT_FOR_PIN: // waiting for pin

// accept number as part of pin

if (mPin.length() == 0)
mScreen.setText("");
mPin += String.valueOf(key);
mScreen.setText(mScreen.getText() +"*");
break;
case MENU_DISPLAYED:

// treat number as menu selection

switch(key){
case 1:
TransMoney();
break;
case 2:
DispenseMoney();
break;
case 3:
CheckBalance();
break;
case 4:
DispenseMoney();
break;
default:
InvalidOption();
}
break;
case TRANSFER_MONEY:
// treat number as part of amount to transfer

if(Transfer.length() == 0)
mScreen.setText("");
Transfer += String.valueOf(key);
mScreen.setText(mScreen.getText() + key );

break;
case DISBURSE_MONEY:
// treat number as part of amount to disburse
if(Transfer.length() == 0)
mScreen.setText("");
Transfer += String.valueOf(key);
mScreen.setText(mScreen.getText() + key );

break;
case CHECK_BALANCE:
break;
}
}

August 25, 2008 at 7:25 PM

private void enter(){
if (state == WAIT_FOR_CARD)
return;

if (state == WAIT_FOR_PIN){
// check pin

if(mPin.equals(PIN)){
// pin correct, display menu
menu();
}
else {
// pin incorrect, display message
clear();
mScreen.setText("Invalid pin, try again (it's " +PIN +")");
}
}

if (state == TRANSFER_MONEY) {
// perform transfer

Transfer1 = Integer.parseInt(Transfer);
accountmoney += Transfer1;

Transfer = "";
Transfer1 = 0;
menu();
}

if (state == DISBURSE_MONEY) {
// perform disburse

Transfer1 = Integer.parseInt(Transfer);
accountmoney -= Transfer1;

Transfer = "";
Transfer1 = 0;
menu();
}
}

// called (by action listener) whenever clear button is pressed

private void clear() {
if (state == WAIT_FOR_CARD)
return;

if (state == WAIT_FOR_PIN) {
mScreen.setText("");
mPin= "";
}
}

// called (by action listener) whenever cancel button is pressed
private void cancel() {
menu();
}

private void menu() {
// display menu
state = MENU_DISPLAYED;
clear();
mScreen.setText(
"1. Transfer money\n" +
"2. WITHDRAWAL money\n" +
"3. Check balance\n"+
"4. SAVING");
}

August 25, 2008 at 7:26 PM


// called (by action listener) whenever receipt button is pressed

private void receipt() {
// display popuup
JOptionPane.showMessageDialog(null, "successfully withdrawal.", "Inane warning",
JOptionPane.WARNING_MESSAGE);

}

// called (by action listener) whenever cash button is pressed
private void cash(){
JOptionPane.showMessageDialog(null, "Transfer your many.", "Inane warning",
JOptionPane.WARNING_MESSAGE);
}

private void quit() {
// quit application
System.exit(0);
}

private void TransMoney() {
clear();
mScreen.setText("How much money would you like to transfer? ...");
state = TRANSFER_MONEY;
}

private void DispenseMoney() {
clear();
mScreen.setText("How much money would you like to take out? ...");

if (Transfer1 > accountmoney) {
mScreen.setText("You can't have more money than you already have");
}

state = DISBURSE_MONEY;
}

private void CheckBalance() {
state = CHECK_BALANCE;
clear();
mScreen.setText("This is the amount of money u have in your account.\n" +
" ---> " + accountmoney);
}

private void InvalidOption() {
clear();
mScreen.setText("You have choose the incorrect option. Try again");
}
}

// the main method that creates a frame, and adds your panel to it so that you can see it.
public static void main(String[] argv) {
Frame frame= new Frame("Simple ATM Example");
frame.add(new ATMPanel());
frame.setSize(500,400);
frame.setResizable(true);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
---------------------------

Thanks & Regards

Amardeep

August 20, 2012 at 6:49 PM

can you give me the code without java.applet type? please give it to me as fast as possible.... i will need it till Wednesday or latest by Thursday.









Related Tutorials/Questions & Answers:
atm machine code - Framework
atm machine code  plz send me the code of atm machine in c#.reply
atm code in servlet& jsp
atm code in servlet& jsp  pls send me the code of ATM project in servlet jsp . my requirements are first of all an user login window open then balance enquiry, withdraw of money, money transfer, then log out. pls send as early
Advertisements
Simple ATM Java Code...
Simple ATM Java Code...  You are required to write a Graphical User Interface that simulates an ATM by building on the program you wrote... list, following which your ATM becomes operational for use by your customers
code for ATM - Java Beginners
code for ATM  How to write code for ATM?  can you plz...://studentblock.com/courses/cs-101/atm-source-code-create-the-database/ Thanks ... javax.swing.event.*; public class ATM extends Applet { public void init
ATM Java Code - Java Beginners
ATM Java Code  how to write ATM code that requirement is 1)user can insert name, account number, current balance,transaction type, 2)if select transaction is money deposit, the value will be input and current balance
ATM IN JAVA RMI - RMI
ATM IN JAVA RMI  How to write code for ATM using Java RMI
ATM machine in c#
ATM machine in c#  i am looking for a code that will be able to create an account and be able to log-in to the atm machine
ATM
ATM Logic - Java Beginners
ATM Logic   Q-In an ATM program i want to print the receipt in which there is information of rupees note that come out from an ATM machine when user... Note: The ATM should check for particular rupee note whether it is available
ModuleNotFoundError: No module named 'atm'
ModuleNotFoundError: No module named 'atm'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'atm' How to remove the ModuleNotFoundError: No module named 'atm' error
atm java program - Java Interview Questions
atm java program  i need an atm system program java code that requires a user to enter his pin.then after entering the pin,it will ask again the user to select from 3 choices such as [1]Inquiry [2]Withdraw [3]Deposit.then if he
Auto Teller Machine Emulator : (ATM Emulator)
Auto Teller Machine Emulator : (ATM Emulator)  following functionalities : a) Create an ATM cash deliver emulator application that will have... as input through ATM machine and give the cash amount. ATM machine has
banking with atm
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code
code  code for android sample program
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance
code
code  write a program to encrypt and decrypt the cipher text "adfgvx"   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import
this is the code
code
Code
code
code
JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
example code
example code  code for displaying a list from another class on a midlet
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
jsp code
jsp code  what are the jsp code for view page in online journal
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code for this   c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 can any one end code
Source code
Source code  source code of html to create a user login page
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code
Code for a triangle.....
Code for a triangle.....   1 1 5 1 1 5 25 5 1 What is the source Code for above output
Code for Pattern
Code for Pattern   * *** * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Code for Pattern
Code for Pattern   * * * * * * * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Code for Pattern
Code for Pattern   * * * * * * * * * * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
JSF code
need jsf code that will populate combo box values from the database  Hi, i'm new on JSf,I need jsf code that will populate combo box values from the database when the form runs
HTML code
HTML code  How do I keep people from stealing my source code and/or images
java code
java code  what is the code to turn off my pc through java program
code - Struts
code  How to write the code for multiple actions for many submit buttons.  use dispatch action
jsp code
jsp code  i want health management system project code using jsp.its urgent
JAVA CODE
JAVA CODE  JAVA SOURCE CODE TO BLOCK A PARTICULAR WEB SITES(SOCIAL WEB SITE
java code
java code  write a java code to convert hindi to english using arrays
code for program
code for program  hello,I am new to java and need to get the code for a program,i've been trying all sorts of code and nothing works any help would... enclosed in inverted commas thank you. BlockquoteHARDWARE ITEMS CODE
Code for Pattern
Code for Pattern   1 23 345 5678 891011 Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Code for Pattern
Code for Pattern  1 121 2342 45674 6789106 Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method

Ads