Question: Figure 1 ---------------- Appendix 1 Determine the birth date from an ID Number. The first 6 digits of the ID Number represents the birth date


Figure 1
----------------
Appendix 1
Determine the birth date from an ID Number.
The first 6 digits of the ID Number represents the birth date of the person. It follows the following format:-
YYmmdd-XX-XXXX
where YY is the year, mm is the month and dd is the day of birth. For example,
941023-07-5222 This person birthday is on 23rd of October (10), 1994. 021113-02-5123 This person birthday is on 13th of November (11), 2002.
*** Special notes on the year ***
As been explained before, the first 2 digits of the ID number will represent the year of birth. There might be a slight confusion on whether the second person (based on the example above) is born in 2002 or 1902. To avoid this problem, we follow the rules below.
If the current year (the year of today) is written in this format, CCcc,
1. If YY is less than or equal to cc, then the birth year of the person is CCYY 2. Otherwise, the birth year of the person is (CC-1)YY.
For example, lets say today is 2nd December 2020. The current year is 2020 (CC=20, cc=20).
For the first person, the YY value is 94 (more than cc). Thus, the birth year of the first person is (CC-1)YY, which is (19)94.
For the second person, the YY value is 02 (less than cc). Thus, the birth year of the second person is CCYY, which is 2002.
Appendix 2
Determine the birth state of the person.
The 2 digits after the birth date will represent the state of birth for the person. Below are the state code representation.
| Johor 01, 21, 22, 23, 24 |
| Kedah 02, 25, 26, 27 |
| Kelantan 03, 28, 29 |
| Melaka 04, 30 |
| Negeri Sembilan 05, 31, 59 |
| Pahang 06, 32, 33 |
| Penang 07, 34, 35 |
| Perak 08, 36, 37, 38 , 39 |
| Perlis 09, 40 |
| Selangor 10, 41, 42, 43, 44 |
| Terengganu 11, 45, 46 |
| Sabah 12, 47, 48, 49 |
| Sarawak 13, 50, 51, 52, 53 |
| Wilayah Persekutuan (Kuala Lumpur) 14, 54, 55, 56, 57 |
| Wilayah Persekutuan (Labuan) 15, 58 |
| Wilayah Persekutuan (Putrajaya) 16 |
| Unknown 82 |
For example,
941023-07-5222 This person was born in Penang (07).
021113-02-5123 This person was born in Kedah (02).
Appendix 3
The last digit of the ID Number can be used to determine the gender of the person. If the last digit is an odd number, the person is Male, and if the digit is an even number, the person is Female.
For example,
941023-07-5222 This person is Female (the last digit is 2, even number). 021113-02-5123 This person is Male (the last digit is 3, odd number).
Continuous Assessment 4 (C6, CO3, PO2) You are required to write a complete Java code for class Person that can be used to store the Identification Number (ID Number) of a person. Details of Person class as shown in Figure 1. Constructor Person (String name. String IDNumber) Construct new Person with provided name and ID Number. Invalid IDNumberException will be thrown if the ID number is not valid. The format for ID number follows Malaysia ID number format which is 6 digits follow by "-", follow by another 2 digits, follow by "-"* and finally another 4 digits. Whitespaces before, in between and after the ID number must be removed for standardization. Below are sample of valid and invalid ID Number: Valid ID Number: 32 23 12-23-23 11 (valid ID Number, whitespaces need to be removed) 123456-12-1234 (valid ID Number, 6 digits follow by "-", then 2 digits then follow by "-", finally 4 4 digits) Invalid ID Number: 12345 12 1234 (invalid ID Number, only 5 digits at the first part of the ID Number) 123456 - A12-1234 (invalid ID Number, consist of alphabet character) Method Summary Modifier and Return Type Method and Description String getName return the name of the person getIDNumber return the ID Number of the person. String int getDayBirth() return the day of the birth date of the person. Refer Appendix 1 for instruction on how to determine the birth date from the ID Number int get Month Birth() return the month of the birth date of the person. Refer Appendix 1 for instruction on how to determine the birth date from the ID Number: int get YearBirth() return the year of the birth date of the person. Refer Appendix 1 for instruction on how to determine the birth date from the ID Number: String getState Birth return the birth state of the person. Refer Appendix 2 for instruction on how to determine the birth state from the ID Number String getGender return the gender of the person (1.e. Male or Female"). Refer Appendix 3 for instruction on how to determine the birth state String from the ID Number: toString return the detailed information of the person using the following format: Name: XXXXXXXXXXXXX ID Number: 123456-12-1234 Date of Birth: dd.mm/YYYY State of Birth: XXXXXXXXXXXX Gender: XXXXXXXXXX
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
