Question

In: Computer Science

Create an application to simulate a bank ATM and you must combine graphical interfaces using Swing...

Create an application to simulate a bank ATM and you must combine graphical interfaces using Swing or AWT and relational databases.

We will have a Bank Accounts database. Each account will have an account number, the name of the owner and the account balance.

The program must allow the following options:

a) Create an account: request the account information and save it in the database.

b) Enter the ATM: it will allow you to request the account number and will go to the next part of the program.

c) Close an account: delete it from the database

d) Exit

The second part of the program will perform the typical tasks of an ATM. It must perform the following:

a) See the account balance: Display the balance of the account. (The account has already been previously registered)

b) Deposit a money in the account: request the value to deposit and increase the balance in that value.

c) Withdraw money: request the value to be withdrawn, and if there is sufficient balance, this balance decreases in the value to be withdrawn.

d) Transfer money to another account: request the number of the other account and the value to be transferred, and if the other account exists and the balance is sufficient, decrease the source account by the indicated value and increase the balance of the other account by The transferred value.

e) Exit.

The program must be written in Java and you can use a desktop database (Access or H2 or Derby or Sqlite or HSQLDB) or a client-server database (MariaDB, MySQL or PostgreSQL).

Solutions

Expert Solution

Programming language: Java

import java.sql.*;

class Bank

{

//Need to declare all the variables required for opening account

private String accNo;

private String name;

private long balance;

Scanner acc=new Scanner(System.in);

//This method is for opening account

try{

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection("jdbc.oracle.thin:@localhost:1521:xe","system","oracle");

PreparedStatement stmt=new PreparedStatement("insert into Account values(?,?,?))";

System.out.println("Enter the account number");

accNo=acc.next();

stmt.setInt(1,accNo);

System.out.println("Enter the name");

name=acc.next();

stmt.setString(2,name);

System.out.println("Enter the balance");

balance=acc.nextLong();

stmt.setLong(3,balance);

int i=stmt.executeUpdate();

System.out.println(i+"accounts are inserted");

con.close();

}catch(Exception e)

{

System.out.println(e);

}

}

//This method to check the atm pin

public void checkPin()

{

Scanner pin=new Scanner(System.in);

//Here based on our choice we can read the pin number or can directly hard code the value

int pin=12345;

System.out.println("Welcome to the bank of ......");

System.out.prinln("Enter your pin");

int entry=pin.nextInt();

while(entry!=pin)

{

System.out.println("\n Incorrect pin try again..");

System.out.println("Enter your pin");

entry=pin.nextInt();

}

System.out.println("/n pin accepted select your options now");

}

//This method is to delete the account

public void deleteAccount()

int status=0;

Scanner pin=new Scanner(System.in);

System.out.println("Enter the account number to delete");

try

{

Connection con=Emp.getConnection();

PreparedStatement ps=con.prepareStatement("delete from emp where id=pin");

ps.setInt(1,accNum);

status=ps.executeUpdate();

con.close();

}

catch(Exception e)

{

e.printStatckTrace()'

}

return status;

}

//This method is for exit

public void exit()

{

System.out.println("Thank you for using ATM.... Have a nice day ....Good bye");

System.exit(0);

}

//This method for ATM operations

public void operations()

{

Scanner op=new Scanner("System.in");

int option;

do

{

System.out.println(" check balance" +\n +"deposit" + \n +"with draw" + \n +"Transfer money " +\n+ "Exit");

System.out.println("Enter your choice");

option=op.nextInt();

switch(option)

{

case 1: 999999999999

}


Related Solutions

Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Simulate an ATM machine. Create ten accounts in an array with id 0, 1, . ....
Simulate an ATM machine. Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100. The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can enter a choice 1 for viewing the current balance, 2 for withdrawing money, 3 for depositing...
Create a simple Swing application that animates a square diagonally across its window once. You may...
Create a simple Swing application that animates a square diagonally across its window once. You may set the size of the window and assume that it doesn’t change. Using Java swing using timers
Create the logic for an application that instantiates an object of the ATM class. Prompt the...
Create the logic for an application that instantiates an object of the ATM class. Prompt the user for the ATM object data to display the user’s bank balance PROGRAMMING LOGIC AND DESIGN QUESTION JAVA LANGUAGE
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
create scientific calculator using java language with OOP rule and interfaces.
create scientific calculator using java language with OOP rule and interfaces.
Graphical User Interfaces using java. Please provide proper commenting so that I understant what is going...
Graphical User Interfaces using java. Please provide proper commenting so that I understant what is going on in the program: Develop a simple tool for analyzing a segment of text that determines the number of words in that segment and the average word length. The application should have a single window with a scrolling text box (JTextArea) and an area to display the statistics. The statistics area should be a panel with a titled border, containing labeled fields that display...
(Not in Swing) Write a JavaFX application that creates polyline shapes dynamically using mouse clicks. Each...
(Not in Swing) Write a JavaFX application that creates polyline shapes dynamically using mouse clicks. Each mouse click adds a new line segment to the current polyline from the previous point to the current mouse position. Allow the user to end the current polyline with the double click. Also, provide a button that clears the window and allows the user to begin again.
You will design and create your own GUI application for the Bank project. This project should...
You will design and create your own GUI application for the Bank project. This project should be designed and written by Java programming. The requirements of the program: 1. The program will be best implemented as a multi-file program for each class. 2. The parameters and return types of each function and class member should be decided in advance. You may need to add more member variables and functions to the classes than those listed below. Also, you can throws...
Create a project plan on the game or application you are creating. Using java programming. The...
Create a project plan on the game or application you are creating. Using java programming. The project plan should include the following: A description of the game or application The IDE or game engine your plan to use to create the game or app and information on how you are going to develop the game or app If you choose to create a game, how are you going to approach the game design and game development process or if you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT