Answer / Part 1 Explaining - OOP(Ex-1) Understanding the scenario ————————— So before we start the coding process we must understand the problem, how Gregorian’s and Ethiopian’s Calendar 📆 work, & how age calculating could be done.
•Okey .... y’all just subtract date of birth from current date😉 easy right !
❓But, how it could be done, mean do we subtract all or each of values such as dates, months & years separately ❓What if month of (date of birth) greater than current month / it becomes negative/ ❓Is each of years months or each of months days differs
YES, YES ....... Yes
📌 This is why we need logic and cases to solve low level problems upward to higher
📣 •Each year has 12 months •Each months has different dates the highest is 31 and the lowest is 28 •Leap year is February which is 2nd month 29 days and on non-leap year 28 days
📣 •Each year has 13 months •Each 12 months has 30 days and the last one has 5 or 6 days •Leap year is Pagume/ጷግሜን which is 13th month 6 days & on non-leap year 5 days —————— 📆 How to calculate Leap Years 📆 Pseudo Code (Gregorian) If (year%4 = 0) February = 29 else February = 28 •Which means if the year is divided by 4 without the remainder then February month has 29 days and the reverse/else which is false means it has 28 days.
Pseudo Code (Ethiopian) If (year%4 = 3) Pagume = 6 else Pagume = 5 •In the Ethiopian calendar leap is different only the reminder which the year divided by 4 is becomes only 3 then it’s leap year otherwise it’s not-leap year. —————— Note: declare months array with the following variables for months days in Gregorian calendar.
NB. February is a variable declared previously on leap year or not-leap year —————— There are two cases to deal with to calculate the age from date of birth (DOB) ⭕️ Case 1: subtracting without carry forwarded Ex: Current: 2019.10.28 DOP: 1992.08.20 ———————— Age : 27 years, 2 months, 8 days
⭕️ Case 1: When we subtract from current date with carry forwarded from month or year Ex: Current: 2019.10.28 DOP: 1992.12.30 ———————— Age : 26, 8, 29
📌So to point the problem in this 👆🏽 example we cannot subtract 30 from 28 it will be come -2 this means there is no date called -2 but we can lend from the month, if we lend from month we must know how many days the month contains so we must check from the array we declared previously. But for the month we can borrow 12 or 13 months from year.
Object Oriented Programming(Ex-1) 1️⃣Create a program by using java or any other OOP platform which calculates age. ————————— The program should include the following: ⭕️ “Main” & “Date” classes ⭕️ accepts Name & dob(date, month, year) ⭕️ accepts CurrentDate(date, month, year) ⭕️ and “CalcAge” function
📌Finally to give a teaser of what the user interaction and display will looks:
Enter Name: Student Enter Date of Birth: Date - 20 Month - 8 Year - 1992 ——————— Enter Current Date: Date - 28 Month - 10 Year - 2019 ——————— Student’s Age is: 27 Y, 2 M, 8 D. ——————— N.B.In the above abbreviation Y, M, D is Years, Months & Dates respectively.
As Always: Have a Lit🔥Figuring-Out Folks 🙌🏽 ————————— Join The Underground Coding Movement! AI Programming @freecodecs
Wondering how the new crop of easy-to-make, highly realistic, real-time digital humans will impact the landscape of games, films, social media, and more? To find out, join Epic Games for the next episode of The Pulse, and stick around for the live Q&A.
Next-gen game platforms are capable of handling realistic characters, but until recently, creating them has been extremely challenging. Now, new tools that make believable, animatable digital humans more accessible to creators bring greater opportunities for realism and player immersion.
Can’t make the live session? Sign up anyway and they’ll send you a link to the recording.