-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavings_Account.java
More file actions
78 lines (70 loc) · 1.83 KB
/
Copy pathSavings_Account.java
File metadata and controls
78 lines (70 loc) · 1.83 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package springlab.SpringLabs;
import java.util.Scanner;
public class Savings_Account {
String username;
int pin;
static double bal;
static double amount;
double balance;
public Savings_Account(String name, int p, double balanc) {
username=name;
pin=p;
balance=balanc;
}
public double Withdraw() {
return bal-amount;
}
public double Deposit() {
return bal+amount;
}
public boolean Overdraft() {
//if () {
//}
return true;
}
public static void main(String[] args) {
Savings_Account Jay = new Savings_Account("Jay",100134,100);
Savings_Account Aileen = new Savings_Account("Aileen", 100190, 1000);
Savings_Account John = new Savings_Account("John", 100153,3213);
Scanner input = new Scanner(System.in);
System.out.println("withdraw or deposit");
String action = input.nextLine();
System.out.println("Type pin");
int key = input.nextInt();
action.toString();
//input.next();
if(action=="withdraw") {
System.out.println("How much?");
amount = input.nextDouble();
if(key==Jay.pin) {
bal = Jay.balance;
System.out.println(Jay.username+":"+bal);
}else if(key == Aileen.pin) {
bal = Aileen.balance;
System.out.println(Aileen.username+":"+bal);
}else if(key == John.pin) {
bal = John.balance;
System.out.println(John.username+":"+bal);
}else {
System.out.println("Incorrect pin");
}
}
else if(action=="deposit") {
input.next();
System.out.println("How much?");
amount = input.nextDouble();
if(key==Jay.pin) {
bal = Jay.balance;
System.out.println(Jay.username+":"+bal);
}else if(key == Aileen.pin) {
bal = Aileen.balance;
System.out.println(Aileen.username+":"+bal);
}else if(key == John.pin) {
bal = John.balance;
System.out.println(John.username+":"+bal);
}else {
System.out.println("Incorrect pin");
}
}
}
}