Posted by Jenny on March 14, 2005 In Reply to: stuck on my assignment (very beginner) posted by Glenn Stewart on March 14, 2005 : Design an algorithm that will prompt for and receive the time expressed in 2400 format (eg 2305 hours), convert it to 12 hour format (eg 11:05 pm.) and display the new time on the screen. Your program is to repeat the processing until six times have been entered, processed and displayed. : Execution of the program may proceed as follows: : Enter time to convert in 24 hour format -> 2305 For the conversion from 2400 format to am/pm you can use this function: function Time2400ToAmPm(T: string): string; var H, M, AmPm: string; begin H := Copy(T, 1, 2); M := Copy(T, 3, 2); if StrToInt(H) > 12 then begin AmPm := 'pm'; H := IntToStr(StrToInt(H) - 12); if Length(H) = 1 then H := '0' + H; end else AmPm := 'am'; Result := H + ':' + M + ' ' + AmPm; end; For the rest, I'm not gonna do your homework. You should look at a good Delphi tutorial ;) for example, at this very site ;) Related Articles and Replies
|
|