89. Parse GPS String for Time and Coordinates

You are given a $GPRMC NMEA string from a GPS module in the following simplified format:

$GPRMC,<time>,<status>,<lat>,<NS>,<long>,<EW>,...

Your task is to:

  • Extract and print:
     
    • UTC time in HH:MM:SS format (first field after $GPRMC)
    • Latitude with direction (lat NS) : NS- North South
    • Longitude with direction (long EW) : EW- East West

Assume:

  • Input will always follow this format
  • You only need to extract and print the first 7 fields
  • Do not validate checksum or GPS fix status
     

Example-1

Input:
$GPRMC,123519,A,4807.038,N,01131.000,E
Output:
Time: 12:35:19  
Latitude: 4807.038 N  
Longitude: 01131.000 E


Example-2

Input:
$GPRMC,083559,A,3745.678,N,12227.890,W
Output:
Time: 08:35:59  
Latitude: 3745.678 N  
Longitude: 12227.890 W


 

Loading...

Input

$GPRMC,123519,A,4807.038,N,01131.000,E

Expected Output

Time: 12:35:19 Latitude: 4807.038 N Longitude: 01131.000 E