ISC 2020 program: Convert day number to date
isc 2020 program 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:
java videos
ISC 2020 program class convert
isc 2020 program 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 dayToDate(): 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 dayToDate() and void display(). Define a main() function to create an object and call the functions accordingly to enable the task.
import java.util.Scanner;
class Convert
{
int n,d,m,y;
String month[]={"","January","February","March","April","May","June","July","August","September","Ocober","November","December"};
Convert()
{
n=0;
d=0;
m=0;
y=0;
}
void accept()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the day number");
n=sc.nextInt();
System.out.println("Enter the year");
y=sc.nextInt();
}
void day_to_date()
{
int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
if((y % 100 == 0 && y % 400 == 0) || y % 4 == 0)
{
day[2]=29;
}
m=1;
while(n>day[m])
{
n=n-day[m];
m++;
}
d=n;
}
void display()
{
System.out.println("THE DATE IS: "+month[m] + d+ ","+" "+y);
}
public static void main()
{
Convert obj=new Convert();
obj.accept();
obj.day_to_date();
obj.display();
}
}
java programs
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.