‹ Back to the paper
Design a class Convert to find the date and the month from a given day number for a particular…
Design a class Convert to find the date and the month from a given day number for a particular year.
Example: If day number is 64 and the year is 2020, then the corresponding date would be:
March 4, 2020 i.e. (31 + 29 + 4 = 64)
Some of the members of the class are given below:
Class name : Convert
Data members/instance variables:
n : integer to store the day number
d : integer to store the day of the month (date)
m : integer to store the month
y : integer to store the year
Methods/Member functions:
Convert ( ) : constructor to initialize the data members with legal initial values
void accept( ) : to accept the day number and the year
void day_to_date( ) : converts the day number to its corresponding date for a particular year and stores the date in ‘d’ and the month in ‘m’
void display( ) : displays the month name, date and year
Specify the class Convert giving details of the constructor( ), void accept( ), void day_to_date( ) and void display( ). Define a main( ) function to create an object and call the functions accordingly to enable the task.
Answer
No answer yet.
From ISC 2020 Computer Science Paper 1, question 7.