-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassbankacc.java
More file actions
63 lines (47 loc) · 1.24 KB
/
Copy pathclassbankacc.java
File metadata and controls
63 lines (47 loc) · 1.24 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
import java.util.*;
public class classbankacc {
String name;
double balance;
int transactions;
classbankacc(String name){
this.name = name;
this.balance = 0;
this.transactions = 0;
}
public void deposit(int amount){
if(amount >= 0 && amount <= 500){
balance = balance + amount;
transactions++;
}
}
public boolean bankFees(int fee){
int totalfee = 0;
for(int i = 1;i<=transactions;i++){
totalfee += i * fee;
}
balance = balance - totalfee;
if(balance > 0){
return true;
}else{
balance = 0;
return false;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
String name = sc.next();
classbankacc acc = new classbankacc(name);
int n = sc.nextInt();
for (int j = 0; j < n; j++) {
int amt = sc.nextInt();
acc.deposit(amt);
}
int fee = sc.nextInt();
System.out.println(acc.bankFees(fee));
}
}
}
}