Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

main menu 1. accept date submenu 2. exit Accept date sub menu 1. Accept date to

ID: 3610647 • Letter: M

Question


  main menu

1. accept date submenu
2. exit


  Accept date sub menu
1. Accept date to convert from mm/dd/yyyy to yyyydddformat
2. Accept date to convert from yyyyddd to mm/dd/yyyyformat
3. Go back to main menu

date_array[0] =0;
date_array[1] = 31;
date_array[2] = 59;
date_array[3] = 90;
date_array[4] = 120;
date_array[5] = 151;
date_array[6] = 181;
date_array[7] = 212;
date_array[8] = 243;
date_array[9] = 273;
date_array[10] = 304;
date_array[11] = 334;


========================================================================

if the user enters 1 fromthe main menu:

then display the"accept date sub menu"
if the user enters 1 from "accept date sub menu" then do thefollowing:

        Acceptmonth from user
Accept day from user
Accept year from the user

   Validate thedate:

   for mm =4.6.9 and 11 the dd must not be > 30
   for mm = 1,2,5,7,8,10 and 12 dd must not be >31
   for mm = 2 the dd
       for leap year dd must not >29
       for non leap year dd must not> 28

   leap year isdivisible by 4 with 0 remainder

  EXAMPLE)

  05/12/2007

   ddd =date_array[5-1]
   ddd = ddd + 12;
   julian = 2007 *1000
   julian = julian + 132

========================================================

if the user enter 2 from "Accept date sub menu":

1. Accept ddd from theuser
   a. Validate ddd = must be between 1 ~ 366
2. Accept yyyy from the user
   a. validate yyyy = must be between 00001 ~ 9999
3. If ddd and yyyy are invalid - display an apporpriate errormessage and redisplay the
   "Accept date sub menu"

4. Use ddd and look for avalue assigned n the date_array
   find a pair in the date_array that satisfies thefollowing:
   date_array[i-1] < ddd < date_array[i]
5. mm = i
6. dd = ddd - date_array[i-1]
7. Display mm/dd/yyyy the result of converting from yyyydddformat


===========================================================

if the user enters 3 from"Accept date sub menu" then go back to main menu

====================================================================

if the user enters 2 fromthe main menu - exit the program.

Explanation / Answer

main menu 1. accept date submenu 2. exit Accept date sub menu 1. Accept date to