forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingsAccountClass.java
More file actions
81 lines (71 loc) · 2.94 KB
/
SavingsAccountClass.java
File metadata and controls
81 lines (71 loc) · 2.94 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
import java.util.Scanner;
/* Date
* Amitoj Jahar
_______________________________________________________________________________
+ SavingsAccountClass +
+_____________________________________________________________________________+
+ -intRate: double +
+ -balance: double +
+____________________________________________________________________________ +
+ +SavingsAccountClass(INTRATE:double, Balance:double) +
+ +deposit(): double +
+ +withdraw(): double +
+ +setInt(): double +
+ +addInterest(Int): double +
________________________________________________________________________________
*/
public class SavingsAccountClass
{
private double intRate;
private double balance;
public SavingsAccountClass (double INTRATE, double Balance)
{
intRate = INTRATE;
balance = Balance;
}
public double deposit()
{
balance = balance + 100;
return balance;
}
public double withdraw()
{
balance = balance - 50;
return balance;
}
public double setInt()
{
double Int = (intRate/12)*balance;
double int1 = Math.round(Int*100.00)/100.00;
return int1;
}
public double addInterest(double Int)
{
balance = balance + Int;
return balance;
}
public static void main(String[] args)
{
SavingsAccountClass test1 = new SavingsAccountClass(0.00, 500.00);
SavingsAccountClass test2 = new SavingsAccountClass(0.12, 500.00);
SavingsAccountClass test3 = new SavingsAccountClass(0.24, 500.00);
System.out.println( "Starting Annual Months Deposits Withdrawals Interest Ending");
System.out.println( "Balance int.rate earned balance");
double Int;
Int = test1.setInt();
test1.deposit();
test1.withdraw();
test1.addInterest(Int);
System.out.println("500"+" "+test1.intRate+" 1 100 50 "+test1.setInt()+" "+test1.balance);
Int = test2.setInt();
test2.deposit();
test2.withdraw();
test2.addInterest(Int);
System.out.println("500"+" "+test2.intRate+" 1 100 50 "+test2.setInt()+" "+test2.balance);
Int = test3.setInt();
test3.deposit();
test3.withdraw();
test3.addInterest(Int);
System.out.println("500"+" "+test3.intRate+" 1 100 50 "+test3.setInt()+" "+test3.balance);
}
}