From d724e35207b7be525fab25829c7bd5a1cc68e393 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:18:14 +0530 Subject: [PATCH 1/8] Branch Created --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1884195..4fad69a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # ATM Mini Java Project + +Transaction Class From 09f44217196c062348b1f2aed37bc9c79487f02b Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:23:01 +0530 Subject: [PATCH 2/8] Initialising and Declaring Objects --- atm/src/atm/Transaction.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 atm/src/atm/Transaction.java diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java new file mode 100644 index 0000000..5cf5cda --- /dev/null +++ b/atm/src/atm/Transaction.java @@ -0,0 +1,13 @@ +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); \ No newline at end of file From 6b430c496b1c4da2ff87666ecb4c1941711132bf Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:23:36 +0530 Subject: [PATCH 3/8] While for Options --- atm/src/atm/Transaction.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index 5cf5cda..8728ca9 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -10,4 +10,14 @@ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter Balance in your Account: "); int balance = sc.nextInt(); - Scanner s = new Scanner(System.in); \ No newline at end of file + 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(); \ No newline at end of file From 5c1a85401033ee85aa6c9cd959f355b6e9940e46 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:24:05 +0530 Subject: [PATCH 4/8] Withdraw Function --- atm/src/atm/Transaction.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index 8728ca9..ac65cb7 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -20,4 +20,22 @@ public static void main(String[] args) { 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(); \ No newline at end of file + 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; \ No newline at end of file From 7340f00ca86d2c94bed06cf49134534d567543f1 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:24:34 +0530 Subject: [PATCH 5/8] Deposit Function --- atm/src/atm/Transaction.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index ac65cb7..2b22fc5 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -38,4 +38,13 @@ public static void main(String[] args) { 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; \ No newline at end of file From 0ab903937ca2f6f1e170ae62abd4b6d0010e2b59 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:25:02 +0530 Subject: [PATCH 6/8] Displaying Total Balance --- atm/src/atm/Transaction.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index 2b22fc5..f9943b4 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -47,4 +47,9 @@ public static void main(String[] args) { 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; \ No newline at end of file From 6542778a02f3e0f557a2ba077909a491ef1b0102 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:25:29 +0530 Subject: [PATCH 7/8] Exit --- atm/src/atm/Transaction.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index f9943b4..afb39e7 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -52,4 +52,9 @@ public static void main(String[] args) { case 3: System.out.println("Balance : "+balance); System.out.println(""); - break; \ No newline at end of file + break; + + case 4: + System.exit(0); + } + } \ No newline at end of file From ec62e1dffefa43d5aa562d3eda7baa3627e6b586 Mon Sep 17 00:00:00 2001 From: Pranit5895 Date: Tue, 20 Apr 2021 20:25:57 +0530 Subject: [PATCH 8/8] Transaction Function for ATM --- atm/src/atm/Transaction.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atm/src/atm/Transaction.java b/atm/src/atm/Transaction.java index afb39e7..3ba89a0 100644 --- a/atm/src/atm/Transaction.java +++ b/atm/src/atm/Transaction.java @@ -57,4 +57,6 @@ public static void main(String[] args) { case 4: System.exit(0); } - } \ No newline at end of file + } + } +}