Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# ATM
Mini Java Project

Transaction Class
62 changes: 62 additions & 0 deletions atm/src/atm/Transaction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package Main;

import java.util.Scanner;

public class Transaction {

public static void main(String[] args) {
// TODO Auto-generated method stub
int withdraw, deposit;
Scanner sc = new Scanner(System.in);
System.out.println("Enter Balance in your Account: ");
int balance = sc.nextInt();
Scanner s = new Scanner(System.in);

while(true)
{
System.out.println("Automated Teller Machine");
System.out.println("Choose 1 for Withdraw");
System.out.println("Choose 2 for Deposit");
System.out.println("Choose 3 for Check Balance");
System.out.println("Choose 4 for EXIT");
System.out.print("Choose the operation you want to perform:");
int n = s.nextInt();

switch(n)
{
case 1:
System.out.print("Enter money to be withdrawn:");
withdraw = s.nextInt();
if(balance >= withdraw)
{
balance = balance - withdraw;
System.out.println("Please collect your money");
System.out.println("Remaining Balance in Your Account is: "+balance);
}
else
{
System.out.println("Insufficient Balance");
}
System.out.println("");
break;

case 2:
System.out.print("Enter money to be deposited:");
deposit = s.nextInt();
balance = balance + deposit;
System.out.println("Your Money has been successfully deposited");
System.out.println("Balance after deposit is: "+balance);
System.out.println("");
break;

case 3:
System.out.println("Balance : "+balance);
System.out.println("");
break;

case 4:
System.exit(0);
}
}
}
}