forked from Adi142857/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
59 lines (50 loc) · 1.45 KB
/
Bank.java
File metadata and controls
59 lines (50 loc) · 1.45 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
import java.util.Scanner;
public class Bank {
long accno;
double balance, temp;
String name;
Scanner S=new Scanner(System.in);
void details()
{
System.out.print("Enter Name:");
name=S.nextLine();
System.out.print("Enter account number:");
accno=S.nextLong();
System.out.print("Enter the Balance:");
balance=S.nextDouble();
}
void deposit() {
System.out.print("Enter Amount to deposited:");
double d=S.nextDouble();
balance = balance + d;
System.out.println("Revised balance:" + balance);
temp = balance;
}
void withdraw() {
System.out.print("Enter amount to be withdrawn:");
double w=S.nextDouble();
if(balance>=w) {
balance=balance-w;
if(balance<500.0) {
balance = temp;
System.out.println("\n=====Transaction not possilbe======");
}
}
else
{
System.out.println("The withdrawal ammount is greater that the available balance");
}
}
void display() {
System.out.println("\nName:" + name);
System.out.println("Account Number:" + accno);
System.out.println("Balance:" + balance);
}
public static void main(String[] args) {
Bank obj= new Bank();
obj.details();
obj.deposit();
obj.withdraw();
obj.display();
}
}