Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Create a class Date_Difference() wherein you declare class BufferedReader and also take an array of int
dataype of name month storing the number of days in each moth i.e. from January to February.
Objective of 1st function : To check whether year is leap or not by taking a parameter y as the year and
returning no. of days in February month as per the validity of the y passed
isLeap(y)
Step 2: if(y mod 400=0) or ((y mod 100 not equal to 0 ) and (y mod 4=0))THEN
Else
[End of if structure]
Objective of 2nd function :To check the validity of the date by taking date in dd , mm , yyyy format as a
parameter and returning true or false as per is valid
dateValidate(d,m,y)
Step 1: month[2]←isLeap(y)
Else
[End of if structure]
Objective of 3rd function :Function to return the day number from the year by taking date , month , year
as the parameters.
Dayno(d,m,y)
Step 1: dn←0
Step 2:month[2]=isLeap(y)
Step 3: i←1
Step 5: dn←dn+month[i]
Step 6:i←i+1
Step 7:dn←dn+d
Step 8: I←1000
Else
Step 10.2:dn←dn+365
[End of if structure]
Step 11:I←I+1
Step 12:return dn
Main function : To call the functions and perform the deemed prerequisites
Step 8:m1← extracts string date1 from p+1 to q and converts it to integer.
Step 9: y1← extracts string date1 from q+1 to end and converts it to integer.
Step 10: String date2←”25/12/”+extracted string date1 from p+1 till end
Step 12: d2← extracts string date 2 from 0 to p and converts it to integer.
Step 13: q← stores index position of last occurrence of “/” in string date2.
Step 14: m2← extracts string date2 from p+1 to q and converts it to integer.
Step 15: y2← extracts string date2 from q+1 to end and converts it to integer.
Step 16:t←0,w←0,a←0,b←0
Step 17.1: if(d1,m1 and y1 are passed as parameters to dateValidate()=true and d2,m2 and y2 are
passed as parameters to dateValidate()=true)THEN
[End of if structure]
Else
[End of if structure]
Else
[End of if structure]
Else
Step 17.2: D←”Invalid date , either syntactically or you haven’t entered the current year number”)
[End of if structure]