-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
76 lines (73 loc) · 1.89 KB
/
Copy pathBank.java
File metadata and controls
76 lines (73 loc) · 1.89 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
/*Create a class for Bank_Customer with appropriate details as a it is data
members.
Write a program to update its savings, current account balance as per the
transactions done by the customers. (use array of objects)*/
import java.util.Scanner;
class Bank
{
String account;
String acch;
String address;
int balance;
Bank()
{
this.account="";
this.acch="";
this.address="";
this.balance=0;
}
Bank(String acc,String name,String add, int bal)
{
this.account=acc;
this.acch=name;
this.address=add;
this.balance=bal;
}
/*void updatebal()
{
}*/
void display()
{
System.out.println("Account no : "+this.account);
System.out.println("Account Holder name : "+this.acch);
System.out.println("Account holder address : "+this.address);
System.out.println("Account Balance : "+this.balance);
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Please enter number how many account holder enter : ");
int n=sc.nextInt();
Bank[] B= new Bank[n];
for(int i=0;i<n;i++)
{
System.out.println("please enter account number : ");
sc.nextLine();
String a=sc.nextLine();
System.out.println("please enter Account holder name : ");
String name=sc.nextLine();
System.out.println("please enter your address : ");
String ad=sc.nextLine();
System.out.println("please enter your Account balance : ");
int b=sc.nextInt();
B[i]=new Bank(a,name,ad,b);
}
for(int i=0;i<n;i++)
{
B[i].display();
}
System.out.println("please enter account number which account balance you want to update into their account ");
sc.nextLine();
String ac=sc.nextLine();
for(int i=0;i<n;i++)
{
if(B[i].account.equals(ac))
{
System.out.println("please enter amount your want update");
int am=sc.nextInt();
B[i].balance=B[i].balance-(am);
B[i].display();
}
}
}
}