Question: using java language date may be specified by three numbers denoting year, month and day of month. If we don't need dates from a deep

using java language
date may be specified by three numbers denoting year, month and day of month. If we don't need dates from a deep past, we can specify years relative to the year 2000(e.g., year 2032 as 32). Assuming that we will not consider the future past the year 2127, we can use numbers from the interval 0,127 for year; such numbers can be written on 7 bits. Month number can occupy 4 bits, as it belongs to the interval 0,15, and for the day we can spend 5 bits (which is enough to store any number from the interval [0,31]. Therefore, full date can be packed in 16 bits and we can store two such dates in one 32-bit int (e.g., beginning and end of a period).
Write a program which defines two dates (from and to), each as three integers (year, month, day). Pack them into one integer. Then unpack the integer and recover these six numbers.
For example, the following programshould print
**** OriginalFrom 2000//2//3 to 2127//11//29**** ReconstructedFrom 2000//2//3 to 2127//11//29
using java language date may be specified by

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!