-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbankingApplication.java
More file actions
116 lines (104 loc) · 3.36 KB
/
bankingApplication.java
File metadata and controls
116 lines (104 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.util.Scanner;
public class bankingApplication {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Bankaccount obj=new Bankaccount("abc","12345");
obj.showdata();
}
}
class Bankaccount
{
String CustomerName;
String CustomerID;
int Balance;
int PreviousTransaction;
Bankaccount(String cname,String cid)
{
CustomerName=cname;
CustomerID=cid;
}
void Deposit(int amt)
{
if(amt!=0)
{
Balance= Balance+amt;
PreviousTransaction=amt;
}
}
void Withdrawal(int amt)
{
if(amt!=0)
{
Balance=Balance-amt;
PreviousTransaction=-amt;
}
}
void getprevioustransaction()
{
if(PreviousTransaction>0)
System.out.println("Deposited Amount:"+PreviousTransaction);
else if(PreviousTransaction<0)
System.out.println("Withdrawn amounts:"+Math.abs(PreviousTransaction));
else
System.out.println("No Transaction occurred");
}
void showdata()
{
int option=0;
Scanner sc=new Scanner(System.in);
System.out.println("WELCOME!!"+CustomerName);
System.out.println("Your Id number is"+CustomerID) ;
System.out.println("\n");
System.out.println("1.Check Balance");
System.out.println("2.Deposit");
System.out.println("3.withdrawal");
System.out.println("4.Previous Transaction");
System.out.println("5.EXIT" );
do{
System.out.println("***********************************************");
System.out.println("Enter a option");
System.out.println("***********************************************");
option=sc.nextInt();
System.out.println("\n");
switch(option)
{
case 1:
System.out.println("***********************************************");
System.out.println("balance="+Balance);
System.out.println("***********************************************");
System.out.println("\n");
break;
case 2:
System.out.println("***********************************************");
System.out.println("Enter the amount to be deposited");
System.out.println("***********************************************");
int a=sc.nextInt();
Deposit(a);
System.out.println("\n");
break;
case 3:
System.out.println("***********************************************");
System.out.println("Enter the amount to be withdrawn");
System.out.println("***********************************************");
int x=sc.nextInt();
Withdrawal(x);
System.out.println("\n");
break;
case 4:
System.out.println("***********************************************");
getprevioustransaction();
System.out.println("***********************************************");
System.out.println("\n");
break;
case 5:
System.out.println("***********************************************");
break;
default:
System.out.println("Invalid Option!!!Please enter again");
break;
}}while(option!=5);
{
System.out.println("thank you for using your services");
}
}
}