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

write a program to determine the time and date corresponding to a elapsed number

ID: 3806466 • Letter: W

Question

write a program to determine the time and date corresponding to a elapsed number of seconds since 00: 00: 00 on 1 January 2016. Have the user input the value of elapsed seconds. The output (to the screen) should be the corresponding hour (in military time), minute, second, day of the month, month name, year, and day of the week name (Sunday – Saturday). Your output should look like the following: 23:59:32 2 January 2018 Tuesday Don’t forget that a leap year has 366 days with 29 days in February. Leap years are years that are evenly divisible by 4, with the exception of those evenly divisible by 100 but not 400. Can you design a pseudo code for this process?

Explanation / Answer

//According to given present date
present_year=2016
present_month="January"
present_date="1"
present_day="Friday"
present_hour=0
present_minute=0
present_second=0

   input<-from user(seconds)//taking imput from the user
   total_seconds=input
   //checking with seconds
   if(total_seconds<60)
       present_second+=total_seconds
   else
       total_minutes=total_seconds/60
       remaining_seconds=total_seconds-total_minutes*60
       present_second+=remaining_seconds
   //checking with minutes
   if(total_minutes<60)
       present_minute+=total_minutes
   else
       total_hours=total_minutes/60
       remaining_minutes=total_minutes-total_hours*60
       present_minute+=remaining_minutes
   //checklng with hours
   if(total_hours<24)
       present_hour+=total_hours
   else
       total_days=total_hours/24
       remaining_hours=total_hours-total_days*24
       present_hour+=remaining_hours
   //checking with days
   total_weeks=total_days/7
   remaining_day=total_days-total_weeks*7
   switch(remaining_day)
       case 1:
           present_day="Friday"
       case 2:
           present_day="Saturday"
       case 3:
           present_day="Sundayday"
       case 4:
           present_day="Monday"
       case 5:
           present_day="Tuesday"
       case 6:
           present_day="Wedday"
       case 7:
           present_day="Thursday"
   //checking with years  
   if(total_days>366)
       while(total_days)
           if(present_year%4==0)
               total_days-=366
               present_year+=1
           if(present_year%4!=4)
               total_days-=365
               present_year+=1
           if(present_year%4!=0&&total_days<365)
               break;
           if(present_year%4==0&&total_days<366)
               break;
   //checking with months and date
   if(total_days<=366)
       while(total_days)
           if(present_month="January")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="February"
                   present_date=0
           if(present_month="February")
               present_date++
               total_days--
               if(present_date==28&&present_year%4!=0)
                   present_month="March"
                   present_date=0
               if(present_date==29&&present_year%4==0)
                   present_month="March"
                   present_date=0
           if(present_month="March")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="April"
                   present_date=0      
           if(present_month="April")
               present_date++
               total_days--
               if(present_date==30)
                   present_month="May"
                   present_date=0      
           if(present_month="May")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="June"
                   present_date=0      
           if(present_month="June")
               present_date++
               total_days--
               if(present_date==30)
                   present_month="July"
                   present_date=0  
           if(present_month="July")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="August"
                   present_date=0  
           if(present_month="August")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="September"
                   present_date=0      
           if(present_month="September")
               present_date++
               total_days--
               if(present_date==30)
                   present_month="October"
                   present_date=0  
           if(present_month="October")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="November"
                   present_date=0  
           if(present_month="November")
               present_date++
               total_days--
               if(present_date==30)
                   present_month="December"
                   present_date=0
           if(present_month="December")
               present_date++
               total_days--
               if(present_date==31)
                   present_month="January"
                   present_date=0
//printing present time
print present_hour:present_minute:present_second present_date present_month present_year present_day