WeixiangYan/CodeTransOcean huggingface dataset:
Task: Horizontal sundial calculations







Python: from __future__ import print_function
import math
try: raw_input
except: raw_input = input

lat = float(raw_input("Enter latitude       => "))
lng = float(raw_input("Enter longitude      => "))
ref = float(raw_input("Enter legal meridian => "))
print()

slat = math.sin(math.radians(lat))
print("    sine of latitude:   %.3f" % slat)
print("    diff longitude:     %.3f" % (lng-ref))
print()
print("Hour, sun hour angle, dial hour line angle from 6am to 6pm")

for h in range(-6, 7):
  hra = 15 * h
  hra -= lng - ref
  hla = math.degrees(math.atan(slat * math.tan(math.radians(hra))))
  print("HR=%3d; HRA=%7.3f; HLA=%7.3f" % (h, hra, hla))





Ada: with Ada.Text_IO;
with Ada.Numerics.Elementary_Functions;
procedure Sundial is
   use Ada.Numerics.Elementary_Functions;
   use Ada.Numerics;
   package Float_IO is new Ada.Text_IO.Float_IO (Float);

   Latitude, Longitude, Meridian : Float;
   Latitude_Sine                 : Float;
begin
   Ada.Text_IO.Put ("Enter latitude:       ");
   Float_IO.Get (Latitude);
   Ada.Text_IO.Put ("Enter longitude:      ");
   Float_IO.Get (Longitude);
   Ada.Text_IO.Put ("Enter legal meridian: ");
   Float_IO.Get (Meridian);
   Ada.Text_IO.New_Line;

   Latitude_Sine := Sin (Latitude * Pi / 180.0);
   Ada.Text_IO.Put_Line
     ("   sine of latitude:" & Float'Image (Latitude_Sine));
   Ada.Text_IO.Put_Line
     ("   diff longitude:" & Float'Image (Longitude - Meridian));
   Ada.Text_IO.New_Line;

   Ada.Text_IO.Put_Line
     ("hour, sun hour angle, dial hour line angle from 6am to 6pm");
   for H in -6 .. 6 loop
      declare
         Hour_Angle : constant Float :=
            15.0 * Float (H) - (Longitude - Meridian);
         Line_Angle : constant Float :=
            Arctan (Latitude_Sine * Tan (Hour_Angle * Pi / 180.0)) * 180.0 /
            Pi;
      begin
         Ada.Text_IO.Put_Line
           ("HR=" &
            Integer'Image (H) &
            "; HRA=" &
            Float'Image (Hour_Angle) &
            "; HLA=" &
            Float'Image (Line_Angle));
      end;
   end loop;
end Sundial;
Task: Horizontal sundial calculations

C: #include <stdio.h>
#include <math.h>

#define PICKVALUE(TXT, VM) do {			\
    printf("%s: ", TXT);			\
    scanf("%lf", &VM);				\
  } while(0);

#if !defined(M_PI)
#define M_PI 3.14159265358979323846
#endif

#define DR(X) ((X)*M_PI/180.0)
#define RD(X) ((X)*180.0/M_PI)

int main()
{
  double lat, slat, lng, ref;
  int h;
  
  PICKVALUE("Enter latitude", lat);
  PICKVALUE("Enter longitude", lng);
  PICKVALUE("Enter legal meridian", ref);
  printf("\n");

  slat = sin(DR(lat));
  printf("sine of latitude: %.3f\n", slat);
  printf("diff longitude: %.3f\n\n", lng - ref);
  
  printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n");
  
  for(h = -6; h <= 6; h++)
  {
    double hla, hra;
    hra = 15.0*h;
    hra = hra - lng + ref;
    hla = RD(atan(slat * tan(DR(hra))));
    printf("HR= %3d;  \t  HRA=%7.3f;  \t  HLA= %7.3f\n",
	   h, hra, hla);
  }

  return 0;
}
Task: Horizontal sundial calculations



C#: using System;

namespace RosettaCode
{
  internal sealed class Program
  {
    private static void Main()
    {
      Func<double> getDouble = () => Convert.ToDouble(Console.ReadLine());
      double h = 0, lat, lng, lme, slat, hra, hla;

      Console.Write("Enter latitude       => ");
      lat = getDouble();
      Console.Write("Enter longitude      => ");
      lng = getDouble();
      Console.Write("Enter legal meridian => ");
      lme = getDouble();

      slat = Math.Sin(lat*2*Math.PI/360);
      Console.WriteLine("\n    sine of latitude:   {0:0.000}", slat);
      Console.WriteLine("    diff longitude:     {0:0.000}\n", lng-lme);
      Console.WriteLine("Hour, sun hour angle, dial hour line angle from 6am to 6pm");
      for (h = -6; h<6; h++)
      {
        hra = 15*h;
        hra -= lng-lme;
        hla = Math.Atan(slat*Math.Tan(hra*2*Math.PI/360))*360/(2*Math.PI);
        Console.WriteLine("HR= {0,7:0.000}; HRA {1,7:0.000}; HLA= {2,7:0.000}", h, hra, hla);
      }
    }
  }
}
Task: Horizontal sundial calculations


C++: #include <cmath>
#include <iostream>
#include <numbers>


static const double DegreesPerHour = 15.0;
static const double DegreesPerRadian = 180.0 * std::numbers::inv_pi;


struct SundialCalculation
{
  double HourAngle;
  double HourLineAngle;
};


class Sundial
{
  
  double m_sinLatitude;
  double m_timeZoneCorrection;
    
public:
  Sundial(double latitude, double longitude, double legalMeridian) noexcept
    : m_sinLatitude(sin(latitude / DegreesPerRadian))
    , m_timeZoneCorrection(legalMeridian - longitude) {}

  SundialCalculation CalculateShadow(double hoursSinceNoon) const noexcept
  {
    double hourAngle = hoursSinceNoon * DegreesPerHour + m_timeZoneCorrection;
    double hourAngleRad = hourAngle / DegreesPerRadian;
    double hlaRad = atan2(m_sinLatitude * sin(hourAngleRad), cos(hourAngleRad));
    double hourLineAngle = hlaRad * DegreesPerRadian;
    return SundialCalculation {hourAngle, hourLineAngle};
  }
};

int main()
{
  double latitude, longitude, legalMeridian;
  std::cout << "Enter latitude:";
  std::cin >> latitude;
  std::cout << "Enter longitude:";
  std::cin >> longitude;
  std::cout << "Enter legal meridian:";
  std::cin >> legalMeridian;
  
  
  const Sundial sundial(latitude, longitude, legalMeridian);
  for(int hour = -6; hour < 7; ++hour)
  {
    
    auto result = sundial.CalculateShadow(hour);

    
    auto amOrPm = hour < 0 ? "am" : "pm";
    auto hourString = std::to_string(hour < 1 ? 12 + hour : hour);
    std::cout << hourString << amOrPm << 
    " - sun hour angle:" << result.HourAngle <<
    ", dial hour line angle:" << result.HourLineAngle << "\n";
  }
}
Task: Horizontal sundial calculations





Java: import java.util.Scanner;

public class Sundial {
    public static void main(String[] args) {
        double lat, slat, lng, ref;
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter latitude: ");
        lat = sc.nextDouble();
        System.out.print("Enter longitude: ");
        lng = sc.nextDouble();
        System.out.print("Enter legal meridian: ");
        ref = sc.nextDouble();
        System.out.println();

        slat = Math.sin(Math.toRadians(lat));
        System.out.printf("sine of latitude: %.3f\n", slat);
        System.out.printf("diff longitude: %.3f\n\n", lng - ref);

        System.out.printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n");

        for (int h = -6; h <= 6; h++) {
            double hla, hra, hraRad;
            hra = 15.0 * h;
            hra = hra - lng + ref;
            hraRad = Math.toRadians(hra);
            hla = Math.toDegrees(Math.atan2(Math.sin(hraRad)*Math.sin(Math.toRadians(lat)), Math.cos(hraRad)));
            System.out.printf("HR= %3d;  \t  HRA=%7.3f;  \t  HLA= %7.3f\n",
                    h, hra, hla);
        }
    }
}
Task: Horizontal sundial calculations







Python: from __future__ import print_function
import math
try: raw_input
except: raw_input = input

lat = float(raw_input("Enter latitude       => "))
lng = float(raw_input("Enter longitude      => "))
ref = float(raw_input("Enter legal meridian => "))
print()

slat = math.sin(math.radians(lat))
print("    sine of latitude:   %.3f" % slat)
print("    diff longitude:     %.3f" % (lng-ref))
print()
print("Hour, sun hour angle, dial hour line angle from 6am to 6pm")

for h in range(-6, 7):
  hra = 15 * h
  hra -= lng - ref
  hla = math.degrees(math.atan(slat * math.tan(math.radians(hra))))
  print("HR=%3d; HRA=%7.3f; HLA=%7.3f" % (h, hra, hla))
Task: Horizontal sundial calculations




Go: package main

import (
    "fmt"
    "math"
    "os"
)

func getnum(prompt string) (r float64) {
    fmt.Print(prompt)
    if _, err := fmt.Scan(&r); err != nil {
        fmt.Println(err)
        os.Exit(-1)
    }
    return
}

func main() {
    lat := getnum("Enter latitude       => ")
    lng := getnum("Enter longitude      => ")
    ref := getnum("Enter legal meridian => ")
    slat := math.Sin(lat * math.Pi / 180)
    diff := lng - ref
    fmt.Println("\n    sine of latitude:   ", slat)
    fmt.Println("    diff longitude:     ", diff)
    fmt.Println("\nHour, sun hour angle, dial hour line angle from 6am to 6pm")
    for h := -6.; h <= 6; h++ {
        hra := 15*h - diff
        s, c := math.Sincos(hra * math.Pi / 180)
        hla := math.Atan2(slat*s, c) * 180 / math.Pi
        fmt.Printf("%2.0f %8.3f %8.3f\n", h, hra, hla)
    }
}
Task: Horizontal sundial calculations



C#: using System;

namespace RosettaCode
{
  internal sealed class Program
  {
    private static void Main()
    {
      Func<double> getDouble = () => Convert.ToDouble(Console.ReadLine());
      double h = 0, lat, lng, lme, slat, hra, hla;

      Console.Write("Enter latitude       => ");
      lat = getDouble();
      Console.Write("Enter longitude      => ");
      lng = getDouble();
      Console.Write("Enter legal meridian => ");
      lme = getDouble();

      slat = Math.Sin(lat*2*Math.PI/360);
      Console.WriteLine("\n    sine of latitude:   {0:0.000}", slat);
      Console.WriteLine("    diff longitude:     {0:0.000}\n", lng-lme);
      Console.WriteLine("Hour, sun hour angle, dial hour line angle from 6am to 6pm");
      for (h = -6; h<6; h++)
      {
        hra = 15*h;
        hra -= lng-lme;
        hla = Math.Atan(slat*Math.Tan(hra*2*Math.PI/360))*360/(2*Math.PI);
        Console.WriteLine("HR= {0,7:0.000}; HRA {1,7:0.000}; HLA= {2,7:0.000}", h, hra, hla);
      }
    }
  }
}








Fortran: program SunDial

  real    :: lat, slat, lng, ref
  real    :: hra, hla
  integer :: h

  real, parameter :: pi = 3.14159265358979323846

  print *, "Enter latitude"
  read *, lat
  print *, "Enter longitude"
  read *, lng
  print *, "Enter legal meridian"
  read *, ref

  print *

  slat = sin(dr(lat))
  write(*, '(A,1F6.3)') "sine of latitude: ", slat
  write(*, '(A,1F6.3)') "diff longitude: ", lng - ref

  print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm"

  do h = -6, 6
     hra = 15.0*h
     hra = hra - lng + ref
     hla = rd( atan( slat * tan( dr(hra) ) ) )
     write(*, '(" HR= ",I3,";  \t  HRA=",F7.3,";  \t  HLA= ", F7.3)'), h, hra, hla
  end do

contains

  function dr(angle)
    real :: dr
    real, intent(in) :: angle
    dr = angle*pi/180.0
  end function dr

  function rd(angle)
    real :: rd
    real, intent(in) :: angle
    rd = angle*180.0/pi
  end function rd

end program SunDial
Task: Horizontal sundial calculations


C++: #include <cmath>
#include <iostream>
#include <numbers>


static const double DegreesPerHour = 15.0;
static const double DegreesPerRadian = 180.0 * std::numbers::inv_pi;


struct SundialCalculation
{
  double HourAngle;
  double HourLineAngle;
};


class Sundial
{
  
  double m_sinLatitude;
  double m_timeZoneCorrection;
    
public:
  Sundial(double latitude, double longitude, double legalMeridian) noexcept
    : m_sinLatitude(sin(latitude / DegreesPerRadian))
    , m_timeZoneCorrection(legalMeridian - longitude) {}

  SundialCalculation CalculateShadow(double hoursSinceNoon) const noexcept
  {
    double hourAngle = hoursSinceNoon * DegreesPerHour + m_timeZoneCorrection;
    double hourAngleRad = hourAngle / DegreesPerRadian;
    double hlaRad = atan2(m_sinLatitude * sin(hourAngleRad), cos(hourAngleRad));
    double hourLineAngle = hlaRad * DegreesPerRadian;
    return SundialCalculation {hourAngle, hourLineAngle};
  }
};

int main()
{
  double latitude, longitude, legalMeridian;
  std::cout << "Enter latitude:";
  std::cin >> latitude;
  std::cout << "Enter longitude:";
  std::cin >> longitude;
  std::cout << "Enter legal meridian:";
  std::cin >> legalMeridian;
  
  
  const Sundial sundial(latitude, longitude, legalMeridian);
  for(int hour = -6; hour < 7; ++hour)
  {
    
    auto result = sundial.CalculateShadow(hour);

    
    auto amOrPm = hour < 0 ? "am" : "pm";
    auto hourString = std::to_string(hour < 1 ? 12 + hour : hour);
    std::cout << hourString << amOrPm << 
    " - sun hour angle:" << result.HourAngle <<
    ", dial hour line angle:" << result.HourLineAngle << "\n";
  }
}









Fortran: program SunDial

  real    :: lat, slat, lng, ref
  real    :: hra, hla
  integer :: h

  real, parameter :: pi = 3.14159265358979323846

  print *, "Enter latitude"
  read *, lat
  print *, "Enter longitude"
  read *, lng
  print *, "Enter legal meridian"
  read *, ref

  print *

  slat = sin(dr(lat))
  write(*, '(A,1F6.3)') "sine of latitude: ", slat
  write(*, '(A,1F6.3)') "diff longitude: ", lng - ref

  print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm"

  do h = -6, 6
     hra = 15.0*h
     hra = hra - lng + ref
     hla = rd( atan( slat * tan( dr(hra) ) ) )
     write(*, '(" HR= ",I3,";  \t  HRA=",F7.3,";  \t  HLA= ", F7.3)'), h, hra, hla
  end do

contains

  function dr(angle)
    real :: dr
    real, intent(in) :: angle
    dr = angle*pi/180.0
  end function dr

  function rd(angle)
    real :: rd
    real, intent(in) :: angle
    rd = angle*180.0/pi
  end function rd

end program SunDial
Task: Horizontal sundial calculations

C: #include <stdio.h>
#include <math.h>

#define PICKVALUE(TXT, VM) do {			\
    printf("%s: ", TXT);			\
    scanf("%lf", &VM);				\
  } while(0);

#if !defined(M_PI)
#define M_PI 3.14159265358979323846
#endif

#define DR(X) ((X)*M_PI/180.0)
#define RD(X) ((X)*180.0/M_PI)

int main()
{
  double lat, slat, lng, ref;
  int h;
  
  PICKVALUE("Enter latitude", lat);
  PICKVALUE("Enter longitude", lng);
  PICKVALUE("Enter legal meridian", ref);
  printf("\n");

  slat = sin(DR(lat));
  printf("sine of latitude: %.3f\n", slat);
  printf("diff longitude: %.3f\n\n", lng - ref);
  
  printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n");
  
  for(h = -6; h <= 6; h++)
  {
    double hla, hra;
    hra = 15.0*h;
    hra = hra - lng + ref;
    hla = RD(atan(slat * tan(DR(hra))));
    printf("HR= %3d;  \t  HRA=%7.3f;  \t  HLA= %7.3f\n",
	   h, hra, hla);
  }

  return 0;
}










Fortran: program SunDial

  real    :: lat, slat, lng, ref
  real    :: hra, hla
  integer :: h

  real, parameter :: pi = 3.14159265358979323846

  print *, "Enter latitude"
  read *, lat
  print *, "Enter longitude"
  read *, lng
  print *, "Enter legal meridian"
  read *, ref

  print *

  slat = sin(dr(lat))
  write(*, '(A,1F6.3)') "sine of latitude: ", slat
  write(*, '(A,1F6.3)') "diff longitude: ", lng - ref

  print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm"

  do h = -6, 6
     hra = 15.0*h
     hra = hra - lng + ref
     hla = rd( atan( slat * tan( dr(hra) ) ) )
     write(*, '(" HR= ",I3,";  \t  HRA=",F7.3,";  \t  HLA= ", F7.3)'), h, hra, hla
  end do

contains

  function dr(angle)
    real :: dr
    real, intent(in) :: angle
    dr = angle*pi/180.0
  end function dr

  function rd(angle)
    real :: rd
    real, intent(in) :: angle
    rd = angle*180.0/pi
  end function rd

end program SunDial
Task: Horizontal sundial calculations





Java: import java.util.Scanner;

public class Sundial {
    public static void main(String[] args) {
        double lat, slat, lng, ref;
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter latitude: ");
        lat = sc.nextDouble();
        System.out.print("Enter longitude: ");
        lng = sc.nextDouble();
        System.out.print("Enter legal meridian: ");
        ref = sc.nextDouble();
        System.out.println();

        slat = Math.sin(Math.toRadians(lat));
        System.out.printf("sine of latitude: %.3f\n", slat);
        System.out.printf("diff longitude: %.3f\n\n", lng - ref);

        System.out.printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n");

        for (int h = -6; h <= 6; h++) {
            double hla, hra, hraRad;
            hra = 15.0 * h;
            hra = hra - lng + ref;
            hraRad = Math.toRadians(hra);
            hla = Math.toDegrees(Math.atan2(Math.sin(hraRad)*Math.sin(Math.toRadians(lat)), Math.cos(hraRad)));
            System.out.printf("HR= %3d;  \t  HRA=%7.3f;  \t  HLA= %7.3f\n",
                    h, hra, hla);
        }
    }
}






Fortran: program SunDial

  real    :: lat, slat, lng, ref
  real    :: hra, hla
  integer :: h

  real, parameter :: pi = 3.14159265358979323846

  print *, "Enter latitude"
  read *, lat
  print *, "Enter longitude"
  read *, lng
  print *, "Enter legal meridian"
  read *, ref

  print *

  slat = sin(dr(lat))
  write(*, '(A,1F6.3)') "sine of latitude: ", slat
  write(*, '(A,1F6.3)') "diff longitude: ", lng - ref

  print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm"

  do h = -6, 6
     hra = 15.0*h
     hra = hra - lng + ref
     hla = rd( atan( slat * tan( dr(hra) ) ) )
     write(*, '(" HR= ",I3,";  \t  HRA=",F7.3,";  \t  HLA= ", F7.3)'), h, hra, hla
  end do

contains

  function dr(angle)
    real :: dr
    real, intent(in) :: angle
    dr = angle*pi/180.0
  end function dr

  function rd(angle)
    real :: rd
    real, intent(in) :: angle
    rd = angle*180.0/pi
  end function rd

end program SunDial
Task: Horizontal sundial calculations







Python: from __future__ import print_function
import math
try: raw_input
except: raw_input = input

lat = float(raw_input("Enter latitude       => "))
lng = float(raw_input("Enter longitude      => "))
ref = float(raw_input("Enter legal meridian => "))
print()

slat = math.sin(math.radians(lat))
print("    sine of latitude:   %.3f" % slat)
print("    diff longitude:     %.3f" % (lng-ref))
print()
print("Hour, sun hour angle, dial hour line angle from 6am to 6pm")

for h in range(-6, 7):
  hra = 15 * h
  hra -= lng - ref
  hla = math.degrees(math.atan(slat * math.tan(math.radians(hra))))
  print("HR=%3d; HRA=%7.3f; HLA=%7.3f" % (h, hra, hla))




Fortran: program SunDial

  real    :: lat, slat, lng, ref
  real    :: hra, hla
  integer :: h

  real, parameter :: pi = 3.14159265358979323846

  print *, "Enter latitude"
  read *, lat
  print *, "Enter longitude"
  read *, lng
  print *, "Enter legal meridian"
  read *, ref

  print *

  slat = sin(dr(lat))
  write(*, '(A,1F6.3)') "sine of latitude: ", slat
  write(*, '(A,1F6.3)') "diff longitude: ", lng - ref

  print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm"

  do h = -6, 6
     hra = 15.0*h
     hra = hra - lng + ref
     hla = rd( atan( slat * tan( dr(hra) ) ) )
     write(*, '(" HR= ",I3,";  \t  HRA=",F7.3,";  \t  HLA= ", F7.3)'), h, hra, hla
  end do

contains

  function dr(angle)
    real :: dr
    real, intent(in) :: angle
    dr = angle*pi/180.0
  end function dr

  function rd(angle)
    real :: rd
    real, intent(in) :: angle
    rd = angle*180.0/pi
  end function rd

end program SunDial
Task: Horizontal sundial calculations

C: #include <stdio.h>
#include <math.h>

#define PICKVALUE(TXT, VM) do {			\
    printf("%s: ", TXT);			\
    scanf("%lf", &VM);				\
  } while(0);

#if !defined(M_PI)
#define M_PI 3.14159265358979323846
#endif

#define DR(X) ((X)*M_PI/180.0)
#define RD(X) ((X)*180.0/M_PI)

int main()
{
  double lat, slat, lng, ref;
  int h;
  
  PICKVALUE("Enter latitude", lat);
  PICKVALUE("Enter longitude", lng);
  PICKVALUE("Enter legal meridian", ref);
  printf("\n");

  slat = sin(DR(lat));
  printf("sine of latitude: %.3f\n", slat);
  printf("diff longitude: %.3f\n\n", lng - ref);
  
  printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n");
  
  for(h = -6; h <= 6; h++)
  {
    double hla, hra;
    hra = 15.0*h;
    hra = hra - lng + ref;
    hla = RD(atan(slat * tan(DR(hra))));
    printf("HR= %3d;  \t  HRA=%7.3f;  \t  HLA= %7.3f\n",
	   h, hra, hla);
  }

  return 0;
}









COBOL: PROGRAM-ID. horizontal-sundial-calc.

DATA DIVISION.
WORKING-STORAGE SECTION.
01  latitude                       PIC S9(3)V9(5) COMP.
01  longitude                      PIC S9(3)V9(5) COMP.
01  legal-meridian                 PIC S9(3)V9(5) COMP.

01  lat-sine                       PIC S9(3)V9(5) COMP.
01  diff-longitude                 PIC S9(3)V9(5) COMP. 

01  lat-sine-disp                  PIC -(3)9.9(5).
01  diff-longitude-disp            PIC -(3)9.9(5).

01  hour                           PIC S9 COMP.
01  sun-hour-angle                 PIC S9(3)V9(5) COMP.
01  dial-hour-line-angle           PIC S9(3)V9(5) COMP. 

01  hour-disp                      PIC 99.
01  sun-hour-angle-disp            PIC -(3)9.9(5).
01  dial-hour-line-angle-disp      PIC -(3)9.9(5).

PROCEDURE DIVISION.
    DISPLAY "Enter latitude: " NO ADVANCING
    ACCEPT latitude
    DISPLAY "Enter longitude: " NO ADVANCING
    ACCEPT longitude
    DISPLAY "Enter legal meridian: " NO ADVANCING
    ACCEPT legal-meridian
    DISPLAY SPACE
    
    COMPUTE lat-sine, lat-sine-disp ROUNDED =
        FUNCTION SIN(latitude * 2 * FUNCTION PI / 360)
    DISPLAY "Sine of latitude: " FUNCTION TRIM(lat-sine-disp)

    SUBTRACT legal-meridian FROM longitude
        GIVING diff-longitude, diff-longitude-disp
    DISPLAY "Diff longitude: " FUNCTION TRIM(diff-longitude-disp)
    DISPLAY SPACE

    DISPLAY "Time   Sun hour angle  Dial hour line angle"
    PERFORM VARYING hour FROM -6 BY 1 UNTIL hour > 6
        COMPUTE sun-hour-angle ROUNDED = hour * 15 - diff-longitude
        COMPUTE dial-hour-line-angle ROUNDED = FUNCTION ATAN(lat-sine
            * FUNCTION TAN(sun-hour-angle * 2 * FUNCTION PI / 360))
            * 360 / (2 * FUNCTION PI)

        ADD 12 TO hour GIVING hour-disp
        MOVE sun-hour-angle TO sun-hour-angle-disp
        MOVE dial-hour-line-angle TO dial-hour-line-angle-disp
        DISPLAY hour-disp ":00 " sun-hour-angle-disp "      "
            dial-hour-line-angle-disp
    END-PERFORM
    .