-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCertificateOfDeposit.java
55 lines (40 loc) · 2.12 KB
/
TestCertificateOfDeposit.java
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
/**
* TestCertificateOfDeposit
*/
import java.util.GregorianCalendar;
import java.util.Scanner;
public class TestCertificateOfDeposit {
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
CertificateOfDeposit certificate1 = new CertificateOfDeposit(), certificate2 = new CertificateOfDeposit();
certificate1 = enterDate(certificate1);
certificate2 = enterDate(certificate2);
displayDate(certificate1);
displayDate(certificate2);
}
public static CertificateOfDeposit enterDate(CertificateOfDeposit certificate){
int tempY,tempM,tempD;
System.out.print("\nEnter a certificate number: ");
certificate.setCertificateNumber(input.nextInt());
input.nextLine();
System.out.print("Enter a name: ");
certificate.setName(input.nextLine());
System.out.print("Enter account balance: ");
certificate.setBalance(input.nextFloat());
input.nextLine();
System.out.print("Enter a Year: ");
tempY = input.nextInt();
System.out.print("Month: ");
tempM = input.nextInt()-1;
System.out.print("Day: ");
tempD = input.nextInt();
input.nextLine();
certificate.setIssueDate(tempY, tempM, tempD);
return certificate;
}
public static void displayDate(CertificateOfDeposit certificate) {
System.out.println("\nID: " + certificate.getCertificateNumber() + "\nAccount Name: " + certificate.getName()
+ "\nBalance: " + certificate.getBalance() + "\nIssue Date: " + certificate.getIssueDate().get(GregorianCalendar.YEAR) + '.' + (certificate.getIssueDate().get(GregorianCalendar.MONTH) + 1) + '.' + certificate.getIssueDate().get(GregorianCalendar.DAY_OF_MONTH)
+ "\nMaturnity date: " + certificate.getMaturityDate().get(GregorianCalendar.YEAR) + '.' + (certificate.getMaturityDate().get(GregorianCalendar.MONTH) + 1) + '.' + certificate.getMaturityDate().get(GregorianCalendar.DAY_OF_MONTH));
}
}