Vous êtes sur la page 1sur 2

Algorithm for weekday_name program:

Step 1: Declare the instance variables as String variables s and wkd, String array wkar
and integer variable d. Initialize wkar with the names of the days available in a week.

Algorithm for weekday_name() constructor:

Step 1: START OF CONSTRUCTOR.


Step 2: Initialize s and wkd with null, and d with 0.
Step 3: END OF CONSTRUCTOR.

Algorithm for accept() function:

Step 1: START OF FUNCTION.


Step 2: Accept a date in DD/MM/YYYY format and store it in s.
Step 3: Accept the first day of that month and store it in wkd.
Step 4: Store only the date from the values in s, in d.
Step 5: END OF FUNCTION.

Algorithm for calc_n_disp () function:

Step 1: START OF FUNCTION.


Step 2: Declare three integer variables i, j and n. Initialize j with 0.
Step 3: Start a loop from i = 0 till I < wkar.length. Check if the value of the ith cell of the
array wkar is same as the value in wkd.
Step 4: If yes, assign the value of i to j and break the loop.
Step 5: Check if d+j < 7. If yes, display the value of (d+j-1)th cell of the array wkar.
Step 6: If not, check if d > j and d < 7. If yes, display the value of (d-j-2)th cell of the array
wkar.
Step 7: If not, check if the value stored in d is divisible by 7. If yes, display the value of
(j-1)th cell of the array wkar.
Step 8: If not, check if the value stored in d is not divisible by 7. If yes, store the value
(d%7)+j-1 in n.
Step 8: Check if n >= 7. If yes, If yes, subtract 7 from n and store it in n. Display the value
of nth cell of the array wkar.
Step 9: If not, display the value of nth cell of the array wkar.
Step 10: END OF FUNCTION.

Algorithm for main() function

PAGE 2.2
Step 1: START OF FUNCTION.
Step 2: Create an object ob of the class.
Step 3: Invoke the function accept() as ob.accept().
Step 4: Invoke the function calc_n_disp() as ob.calc_n_disp().
Step 5: END OF FUNCTION.

PAGE 2.3

Vous aimerez peut-être aussi