ATM Project 1
ATM Project 1
code-------------------------------------------------
show databases;
use Project2;
show tables;
-------------------------------------java-
code-----------------------------------------------
package GG1.JdbcProject;
import java.util.*;
import java.sql.*;
class Project2 {
//method for balance checking:-
public int getBalance(int pin) throws Exception{
Connection con1 =
DriverManager.getConnection("jdbc:mysql://localhost:3306/Project2","root","Root123$
");
rs2.next();
int existing_amount = rs2.getInt(1);
st2.close();
con1.close();
return existing_amount;
}
Connection con2 =
DriverManager.getConnection("jdbc:mysql://localhost:3306/Project2","root","Root123$
");
st2.close();
con2.close();
Connection con3 =
DriverManager.getConnection("jdbc:mysql://localhost:3306/Project2","root","Root123$
");
con3.close();
st3.close();
st4.close();
st4.close();
//Statement creation.
Statement st1 = con.createStatement();
//Resultset.
ResultSet rs1 = st1.executeQuery(Pins);
while(rs1.next()) {
//adding the values in arraylist with using add method.
Atm_pins1.add(rs1.getInt(1));
}
boolean T = true;
while(T) {
Connection con5 =
DriverManager.getConnection("jdbc:mysql://localhost:3306/Project2","root","Root123$
");
if (Atm_pins1.contains(pin)) {
rs5.next();
String account_hoder_name = rs5.getString(1);
T = false;
boolean G = true;
while(G) {
G = false;
if(choice == 1) {
p1.deposit(pin,balance_amount,var);
else if(choice == 3) {
if (withdrawal_amount<p1.getBalance(pin)) {
p1.withdrawal(pin,balance_amount,var,withdrawal_amount);
System.out.println("Successfully withdrawal the amount");
System.out.println("Would you like to display the balance
amount on the screen.");
System.out.println("If Yes: Please enter 1 : ");
System.out.println("If No: Please enter 2 : ");
int s1 = var.nextInt();
if (s1 == 1) {
System.out.println("Amount: "+ p1.getBalance(pin));
System.out.println("Thank you.");
}
else {
System.out.println("Thank you.");
}
}
else {
System.out.println("Insufficient balance!!!");
System.out.println("Check the balance :");
System.out.println("If Yes: Please enter 1 : ");
System.out.println("If No: Please enter 2 : ");
int s2 = var.nextInt();
if (s2 == 1) {
System.out.println("Amount: "+
p1.getBalance(pin));
System.out.println("Thank you.");
}
else {
System.out.println("Thank you.");
}
}
}
else if(choice == 4) {
p1.pinChange(pin,var);
}
else{
System.out.println("Please enter valid pin number.");
T=true;
}
}
}
----------------------------------------
output----------------------------------------