-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountCheck.java
49 lines (47 loc) · 1.11 KB
/
AccountCheck.java
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
import java.util.*;
class BankAccount{
int accno;
String name;
int balance;
final int minBalance=100;
private boolean checkMinBalance(int amount){
if(balance-amount<=minBalance){
return false;
}
else{
return true;
}
}
public BankAccount(int a,String n, int b){
this.accno=a;
this.name=n;
this.balance=b;
}
public void balance(){
System.out.println(balance);
}
public void deposit(int amount){
balance=balance+amount;
}
public void withdraw(int amount){
if(checkMinBalance(amount)){
balance=balance-amount;
}
else{
System.out.println("Transaction failed");
}
}
}
public class AccountCheck{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int amnt=sc.nextInt();
int amnt1=sc.nextInt();
BankAccount b=new BankAccount(1890,"Rahul",1000);
b.deposit(amnt);
b.balance();
b.withdraw(amnt1);
b.balance();
sc.close();
}
}