-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbank.java
More file actions
90 lines (71 loc) · 3.23 KB
/
bank.java
File metadata and controls
90 lines (71 loc) · 3.23 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
79
80
81
82
83
84
85
86
87
88
89
90
import java.util.Scanner;
public class bank {
public static void main(String[] args) {
double moneyinaccount;
int pin;
double amount;
String paylater;
int paylatertimespan;
int totalpintrys;
totalpintrys = 2;
try {
Scanner input = new Scanner(System.in);
// welcome
System.out.println("hello and welcome to the secure server of the bank");
System.out.println("how much money do you have?");
moneyinaccount = input.nextDouble();
System.out.println("please type in you secure pin");
// pin
while (totalpintrys >= 0) {
pin = input.nextInt();
if (pin == 1234) {
System.out.println("pin correct!");
System.out.println("please enter your amount");
amount = input.nextDouble();
if (amount > moneyinaccount) {
System.out.println("you dont have enough money");
System.exit(0);
}
else {
if (amount > 1000) {
System.out.println(
"the amount is over the limit of 1000€ \n do you want to pay later? \n yes / no");
paylater = input.next();
if (paylater.contains("y")) {
System.out.println("over how many moths do you want to pay?");
paylatertimespan = input.nextInt();
System.out
.println("you have to pay a total amount of " + amount + "€ over a timespan of "
+ paylatertimespan + " months! each month you will be paying "
+ (amount / paylatertimespan) + "€");
System.exit(0);
}
else {
System.out.println("ok then earn more money");
System.exit(0);
}
}
else {
System.out.println("transaction successful");
System.out.println("you now have " + (moneyinaccount - amount) + "€ in your account");
System.exit(0);
}
}
}
else if (totalpintrys >= 1) {
System.out.println("wrong pin \n you have " + totalpintrys + " trys left");
System.out.println("try again");
totalpintrys = (totalpintrys - 1);
}
else if (totalpintrys == 0) {
totalpintrys = (totalpintrys - 1);
System.out.println("2 wochen timeout wegen hausmodifikationen");
System.exit(0);
}
}
} catch (Exception e) {
System.out.println("something went terribly wrong");
System.exit(0);
}
}
}