-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIT2A_Group14_Lab1B.java
More file actions
192 lines (147 loc) · 7.26 KB
/
Copy pathIT2A_Group14_Lab1B.java
File metadata and controls
192 lines (147 loc) · 7.26 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* Program that reads a customers' accounts at the end of each month.
* The bank offers two types of accounts: savings and checking
* Group 14
* Authors: Lobingco, Kenneth F.
* Islanan, Lenito Laurencio Lamberto
* Del Rosario, Editha
* Laboratory Exercise 1
* Date: September 14, 2021
*
* */
import java.util.*;
public class IT2A_Group14_Lab1B
{
public static double savingsPrice = 10000; //minimum savings balance
public static double checkingPrice = 50000; //minimum check balance
public static double savingsInterest = 0.03;
public static double checkMinInterest = 0.02;
public static double checkNotMinInterest = 0.04;
public static double serviceCharge_S = 100.00; // service Charge in savings
public static double serviceCharge_C = 500.00; // service Charge in checking
public static double currentBalance;
public static double currentBalCheck;
public static double appliedInterest_S; //apply Interest in savings
public static double appliedInterest_C; //apply interest in checking
public static double appliedInterest_C_Two; //apply interest in checking
public static double newBalance;
public static double newBalCheck;
public static double newBalMinInterestCheck;
public static double newBalMaxInterestCheck;
public static double newBalCheckFiftyOneHundred;
public static double newBalCheckOneHundred;
//below minimum balance receives charge of 100.00 for savings
//below minimum balance receives charge of 500.00 for checking
//Note: cannot call a method to another method
public static double savingsSub_Method (double aSave, double bSave) {
double resultSave = aSave - bSave;
return resultSave;
}
public static double savingsInterestMethod (double aInterestSave, double bInterestSave) {
double resultInterest = aInterestSave * bInterestSave;
return resultInterest;
}
public static double chargeSub_CheckMethod (double aCheck, double bCheck) {
double resultCheck = aCheck - bCheck;
return resultCheck;
}
public static double notMinCheckMethod (double aNotMinCheck, double bNotMinCheck) {
double resultCheckNotMin = aNotMinCheck * bNotMinCheck;
return resultCheckNotMin;
}
public static double maxMin_CheckMethod (double aMaxCheck, double bMaxCheck) {
double resultMaxCheck = aMaxCheck * bMaxCheck;
return resultMaxCheck;
}
public static void main (String [] args) {
boolean program = true;
Scanner read = new Scanner (System.in);
do {
System.out.print("Enter Account No: ");
int accountNumber = read.nextInt();
System.out.println("");
System.out.print("Account Type: ");
char accountType = read.next().charAt(0);
System.out.println("");
switch (accountType) {
//This case is for running savings method
case 's':
case 'S':
System.out.print("Current Balance: ");
currentBalance = read.nextDouble();
System.out.println("");
if (currentBalance < savingsPrice) {
double subCurrent_Charge = savingsSub_Method(currentBalance,serviceCharge_S); //Subtracts charge from savings
newBalance = subCurrent_Charge;
String format = "%-10s %15s %15s %15s %15s %15s\n";
Date dateToday = new Date();
System.out.println("Run Date: " + dateToday);
System.out.printf(format, "Account No", "Account Type", "Current Balance", "Interest", "Service Charge", "New Balance");
System.out.printf(format, accountNumber, accountType, currentBalance, "", serviceCharge_S, newBalance);
}
else if (currentBalance > savingsPrice) {
appliedInterest_S = savingsInterestMethod(currentBalance, savingsInterest); //Multiplies interest to savings
newBalance = currentBalance + appliedInterest_S;
String format = "%-10s %15s %15s %15s %15s %15s\n";
Date dateToday = new Date();
System.out.println("Run Date: " + dateToday);
System.out.printf(format, "Account No", "Account Type", "Current Balance", "Interest", "Service Charge", "New Balance");
System.out.printf(format, accountNumber, accountType, currentBalance, appliedInterest_S, "", newBalance);
}
else if (currentBalance == savingsPrice) {
}
break;
//This case is for running the checking methods
case 'c':
case 'C':
System.out.print("Current Balance: ");
currentBalCheck = read.nextDouble();
if (currentBalCheck < checkingPrice) {
double checkBalanceToCharge = chargeSub_CheckMethod(currentBalCheck, serviceCharge_C);
newBalCheck = checkBalanceToCharge;
String format = "%-10s %15s %15s %15s %15s %15s\n";
//String formatDouble = "%-10d %15.2f %15.2f %15.2f %15.2f %15.2f";
Date dateToday = new Date();
System.out.println("Run Date: " + dateToday);
System.out.printf(format, "Account No", "Account Type", "Current Balance", "Interest", "Service Charge", "New Balance");
System.out.printf(format, accountNumber, accountType, currentBalCheck, "", serviceCharge_C, newBalCheck);
}
else if (currentBalCheck > 50000 && currentBalCheck <= 100000) {
appliedInterest_C = notMinCheckMethod(currentBalCheck, checkNotMinInterest);
newBalMinInterestCheck = appliedInterest_C;
newBalCheckFiftyOneHundred = newBalMinInterestCheck + currentBalCheck;
String format = "%-10s %15s %15s %15s %15s %15s\n";
String formatDouble = "%-10d %15.2f %15.2f %15.2f %15.0f %15.2f";
Date dateToday = new Date();
System.out.println("Run Date: " + dateToday);
System.out.printf(format, "Account No", "Account Type", "Current Balance", "Interest", "Service Charge", "New Balance");
System.out.printf(format, accountNumber, accountType, currentBalCheck, newBalMinInterestCheck, "", newBalCheckFiftyOneHundred);
}
else if (currentBalCheck > 100000) {
appliedInterest_C_Two = maxMin_CheckMethod(currentBalCheck, checkMinInterest);
newBalMaxInterestCheck = appliedInterest_C_Two;
newBalCheckOneHundred = newBalMaxInterestCheck + currentBalCheck;
String format = "%-10s %15s %15s %15s %15s %15s\n";
String formatDouble = "%-10d %15.2f %15.2f %15.2f %15.0f %15.2f";
Date dateToday = new Date();
System.out.println("Run Date: " + dateToday);
System.out.printf(format, "Account No", "Account Type", "Current Balance", "Interest", "Service Charge", "New Balance");
System.out.printf(format, accountNumber, accountType, currentBalCheck, newBalMaxInterestCheck, "", newBalCheckOneHundred);
}
break;
default: System.out.println("ERROR, invalid input");
}
System.out.println("Try Again? (Y/N)");
char tryAgain = read.next().charAt(0);
if (tryAgain != 'y' && tryAgain != 'Y' && tryAgain != 'n' && tryAgain != 'N') {
do {
System.out.println("Try Again? (Y/N)");
tryAgain = read.next().charAt(0);
} while (tryAgain != 'y' && tryAgain != 'Y' && tryAgain != 'n' && tryAgain != 'N');
}
else if (tryAgain == 'n' || tryAgain == 'N') {
System.exit(0);
}
} while (program == true);
}
}