We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 27
) Bentoetsiajon x
1 package com.sjs.banking;
2eimport java.util.ArrayList;.]
4
5 class BankDetails {
6 private String accno;
7 private String name;
8 private String acc type;
9 private long balance;
10 private ArrayList loans = new ArrayList<>();
a Scanner sc = new Scanner(System. in);
12
13 // Existing methods...
14
15* public void openAccount() {
16 System.out.print("Enter Account No: ");
17 accno = sc.next();
18 System.out.print("Enter Account type: ");
19 acc_type = sc.next();
20 System.out.print("Enter Name: ")5
24 name = sc.next();
22 System.out.print(“Enter Balance:
23 balance = sc.nextLong();
2a}1 BankDetasjave %
25
26° public void showAccount() {
27 System.out.print1n("Name of account holder: " + name);
28 System.out.println("Account no.: " + accno);
29 System.out.print1n("Account type: " + acc_type);
30 System.out.printIn("Balance: " + balance);
31 if (loans.size() > @) {
32 System.out.print1n("Loans
33 for (Loan loan : loans) {
34 loan. showLoanDetails();
35 }
36 } else {
37 System.out.println("No loans taken
38 }
39 }
40
41° public void deposit() {
42 long amt;
43 System.out.println("Enter the amount you want to deposit:
44 amt = sc.nextLong();
45 balance = balance + amt;
46 (}48° public void withdrawal() {
49 ong amt;
se System.out.printin("Enter the amount you want to withdraw:
51 amt = Se.nextLong();
52 if (balance >= amt) {
53 balance = balance - amt}
54 System.out.println("Balance after withdrawal: " + balance);
55 } else {
56 System.out.print1n("Your balance is less than " + amt + "\tTransaction failed...1!");
57 }
ss}
59
6@- public boolean search(String ac_no) {
61 af (accno.equals(ac_no)) {
62 showAccount() ;
63 return true;
64 }
65 return false;
6}68° public void applyLoan() {
69 System.out.println("Enter Loan Type (Personal/Home/Study): "
70 String loanType = sc.next();
74 System.out.print1n("Enter Loan Amount: "
72, double loanAmount = sc.nextDouble();
73 System.out.println("Enter Interest Rate: ");
74 double interestRate = sc.nextDouble();
75 System.out.println("Enter Loan Term (in years):
76 int loanTerm = sc.nextInt();
77
78 Loan loan = new Loan(loantype, loanAmount, interestRate, loanTerm);
739 loans. add (oan);
80 system.out.print1n(loantype + “ Loan applied successfully.
si}
82
83° public void displayBalance() {
84 System.out.print1n("Current balance: " + balance);
35 }
36 }JP -Losnsmia
1 package com.sjs.banking;
2 class Loan {
3 private String loanType;
4 private double loanAmount;
5 private double interestRate;
6 private int loanTerm; // in years
7
8° public Loan(String loanType, double loanAmount,
9 double interestRate, int loanTerm) {
i) this.loanType = loanType;
AL this.loanAmount = loanAmount;
n2 this.interestRate = interestRate;
13 this.loanTerm = loanTerm;
a4 }
15
16° public void showLoanDetails() {
A7 System.out.printin("Loan Type: " + loanType);
as System.out.printin("Loan Amount: " + loanAmount);
19 System.out.printin("Interest Rate: "+ interestRate + "%");
20 System.out.printin("Loan Term: " + loanTerm + " years");
21 }
22}
23ID ringtones
1 package com.sjs.banking;
import java.util.Scanner;
3
4
5 public class BankingApp {
6 public static void main(String arg[]) {
7
8
9
Scanner sc = new Scanner(System. in);
// Create initial accounts
system.out.print("How many number of customers do you want to input? ");
int n = sc.nextInt();
BankDetails[] C = new BankDetails[n];
for (int i = 0; i < C.length; itt) {
C[i] = new Bankvetails();
C[i] openaccount();
3
7/ Loop runs until number 7 is not pressed to exit
int ch;18 do {
19 system.out.print1n("\n ***Banking System Application***
20 System.out.println("1. Display all account details\n"
21 +."2. Search by Account number\n"
22 +"3. Deposit the amount\n"
23 +."4. Withdraw the amount\n"
24 +."5. Apply for a Loan\n"
¢ e
Balance\n"
27 system.out.print1n("enter your choice: ");
28 ch = sc.nextInt();
29 switch (ch) {
30 case 1:
31 for (int i = 0; i < C.length; i++) {
32 CLi] .showAccount()
33 }
34, break;case 2:
System.out.print("Enter account no. you want to search:
string ac_no = sc.next();
boolean found = false;
for (int i = @; i < C.length; i++) {
found = C[i].search(ac_no);
if (found) {
break;
+
+
if (found) {
System.out.print1n("Search failed! Account doesn't exist. 5
+
break;print(“Enter Account no.
7 enext() 5
found = false;
for (int i = 0; i < C.lengths i++) {
found = C[i].search(ac_no);
if (found) {
C[i] deposit();
break;
}
t
if (1found) {
system.out.println("Search failed! Account doesn't exist..!!")
+
break;case 4:
System.out .print("Enter Account Né
ac_no = sc.next();
found = false;
for (int i = @; i < C.length; i++) {
found = C[i].search(ac_no);
if (found) {
C[i] .withdrawal() 5
break;
t
+
if (!found) {
system.out.printIn("Search failed! Account doesn't exist..!!");
t
break;79
80
81
82
83
84
86
87
88
89
90
91
92
93
case 5:
system. print("Enter Account No :
ac_no = sc.next();
found = false;
for (int i = @; i < C.length; i++) {
found = C[i].search(ac_no);
if (found) {
CLi]-applyLoan() 5
break;
+
}
if (!found) {
system.out.printIn("Search failed! Account doesn't exist..!
}
break;94
95
96
97
98
99
100
101
102
103
104
105
196
107
108
case 6:
system.out.print("Enter Account No :
ac_no = sc.next();
found = false;
for (int i = 0; i < C.length; i++) {
found = C[i].search(ac_no);
if (found) {
C[i].displayBalance();
break;
t
+
if (!found) {
System.out.printIn("Search failed! Account doesn't exist..!!")5
+
break;case 7:
system.out.println("See you soon...")5
break;
default:
system.out.printIn("Invalid choice! Please enter again.
break;
}
} while (ch != 7)5How many number of customers do you want to input? 2
Enter Account No: 12345
Enter Account type: Saving
Enter Name: Khushi
Enter Balance: 50000
Enter Account No: 9876
Enter Account type: Current
Enter Name: Radha
Enter Balance: 90000***Banking System Application***
. Display all account details
» Search by Account number
. Deposit the amount
» Withdraw the amount
. Apply for a Loan
» Display Balance
» Exit
Enter your choice:
1
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 5e@@e0
No loans taken.
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 90000
No loans taken.
NOU BWR***Banking System Application***
1.
2.
3.
4.
5.
6.
7.
Display all account details
Search by Account number
Deposit the amount
Withdraw the amount
Apply for a Loan
Display Balance
Exit
Enter your choice:
2
Enter account no. you want to search: 12345
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 5@000
No loans taken.***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
3
Enter Account no. : 7@@0@
Search failed! Account doesn't exist..!!***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
3
Enter Account no. : 12345
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 50000
No loans taken.
Enter the amount you want to deposit:
79999***Banking System Application***
Display all account details
Search by Account number
. Deposit the amount
Withdraw the amount
Apply for a Loan
Display Balance
- Exit
Enter your choice:
6
Enter Account No : 12345
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 129999
No loans taken.
Current balance: 129999
SOU BWNR***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
4
Enter Account No : 9876
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 90000
No loans taken.
Enter the amount you want to withdraw:
12479
Balance after withdrawal: 77521***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
5
Enter Account No : 9876
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 77521
No loans taken.
Enter Loan Type (Personal/Home/Study) :
Personal
Enter Loan Amount:
1000000Enter Loan Amount:
16800800
Enter Interest Rate:
13
Enter Loan Term (in years):
5
Personal Loan applied successfully.
***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
6
Enter Account No : 9876
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 77521
Loans:
Loan Type: Personal
Loan Amount: [email protected]
Interest Rate: 13.0%
Loan Term: 5 years
Current balance: 77521***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
5
Enter Account No : 12345
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 129999
No loans taken.
Enter Loan Type (Personal/Home/Study):
Home
Enter Loan Amount:
2500800
Enter Interest Rate:
9
Enter Loan Term (in years):
20
Home Loan applied successfully.***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
6
Enter Account No : 12345
Name of account holder: Khushi
Account no.: 12345
Account type: Saving
Balance: 129999
Loans:
Loan Type: Home
Loan Amount: 2500000.0
Interest Rate: 9.0%
Loan Term: 20 years
Current balance: 129999***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
5
Enter Account No : 98/76
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 77521
Loans:
Loan Type: Personal
Loan Amount: 1000000.0
Interest Rate: 13.0%
Loan Term: 5 yearsEnter Loan Type (Personal/Home/Study):
Study
Enter Loan Amount:
5800088
Enter Interest Rate:
11
Enter Loan Term (in years):
4
Study Loan applied successfully.
***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
6Enter your choice:
6
Enter Account No : 9876
Name of account holder: Radha
Account no.: 9876
Account type: Current
Balance: 77521
Loans:
Loan Type: Personal
Loan Amount: 1696600.0
Interest Rate: 13.0%
Loan Term: 5 years
Loan Type: Study
Loan Amount: [email protected]
Interest Rate: 11.0%
Loan Term: 4 years
Current balance: 77521
***Banking System Application***
1. Display all account details
2. Search by Account number
3. Deposit the amount
4. Withdraw the amount
5. Apply for a Loan
6. Display Balance
7. Exit
Enter your choice:
i
See you soon...