Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 791e1c3

Browse files
Banking System using OOP
1 parent ced5212 commit 791e1c3

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

‎Simple-Banking-System/banking.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import java.util.Scanner;
2+
// Banking System
3+
// class Account---name,balance,credit
4+
// 2 method----1. Deposit 2. Withdraw
5+
// Constraint... balance<3000 ==> print...
6+
7+
class Account {
8+
String name;
9+
double balance;
10+
11+
Account(String n, double m) {
12+
name = n;
13+
balance = m;
14+
}
15+
16+
void deposit(double sal) {
17+
balance += sal;
18+
}
19+
20+
void withdraw(double with) {
21+
balance -= with;
22+
if (balance < 3000) {
23+
System.out.println("Minimum balance not maintained!");
24+
}
25+
}
26+
27+
void display() {
28+
System.out.println("The account balance is: " + balance);
29+
}
30+
}
31+
32+
class banking {
33+
public static void main(String[] args) { // args[0]-name, args[1]-balance
34+
String fullName = args[0];
35+
double bal = Integer.parseInt(args[1]);
36+
Account person1 = new Account(fullName, bal);
37+
boolean i = true;
38+
while (i) {
39+
Scanner myObj = new Scanner(System.in);
40+
System.out.println("1. Deposit\n2. Withdraw\n3. See Balance: ");
41+
int option = myObj.nextInt();
42+
switch (option) {
43+
case 1:
44+
System.out.println("Enter balance:");
45+
double blnce1 = myObj.nextDouble();
46+
person1.deposit(blnce1);
47+
break;
48+
case 2:
49+
System.out.println("Enter balance:");
50+
double blnce2 = myObj.nextDouble();
51+
person1.withdraw(blnce2);
52+
break;
53+
case 3:
54+
person1.display();
55+
break;
56+
default:
57+
i = false;
58+
break;
59+
}
60+
}
61+
62+
}
63+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /