Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


lancau
code for ATM
7 Answer(s)      6 years ago
Posted in : Java Beginners



Advertisement
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 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 IN JAVA RMI - RMI
ATM IN JAVA RMI  How to write code for ATM using Java RMI
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
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
code
code  code for android sample program
code
code    how to write this in java
Code
Code  code for connecting c lang to database
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: import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.
JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
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
jsp code
jsp code  what are the jsp code for view page in online journal
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
example code
example code  code for displaying a list from another class on a midlet
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
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
"Urgent" convert this code to GUI - Swing AWT
"Urgent" convert this code to GUI   please convert for me this code...; } } // class ATM import javax.swing.*; import java.awt.*; public class ATM...; public ATM() { userAuthenticated=false; currentAccountNumber=0; screen=new Screen
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
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
java code
java code  write a java code to convert hindi to english using arrays
JAVA CODE
JAVA CODE  JAVA SOURCE CODE TO BLOCK A PARTICULAR WEB SITES(SOCIAL WEB SITE
jsp code
jsp code  i want health management system project code using jsp.its urgent
code - Struts
code  How to write the code for multiple actions for many submit buttons.  use dispatch action
java code
java code  what is the code to turn off my pc through java program
HTML code
HTML code  How do I keep people from stealing my source code and/or images
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
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW... urgent. // class ATM import javax.swing.*; import java.awt.*; public class ATM { private boolean userAuthenticated; private int currentAccountNumber
java code
java code  I need the java code that would output the following: HARDWARE ITEMS CODE DESCRIPTION UNIT PRICE K16 Wood screws,brass,20mm $7.75 D24 Wood glue,clear,1 liter $5.50 M93
program code
program code  I need to get the code for the following,the user's input are enclosed in curly brackets,thank you. HARDWARE ITEMS CODE DESCRIPTION... 23} ADDRESS-2: {Building 8} ADDRESS-3: {Winchester} POST CODE: {89763} ENTER
Advertisements
 

 

 

DMCA.com