Advertisement
Guest User

Untitled

a guest
Oct 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 1.49 KB | None | 0 0
  1. with Ada.Text_IO;use Ada.Text_IO;
  2. with Ada.Integer_Text_IO;use Ada.Integer_Text_IO;
  3.  
  4. procedure Tider is
  5.    
  6.    type Tid1_type is record
  7.       H1:Integer;
  8.       M1:Integer;
  9.    end record;
  10.    
  11.    type Tid2_type is record
  12.       H2:Integer;
  13.       M2:Integer;
  14.       end record;
  15.    
  16.    procedure GetTid1(A : out Tid1_Type) is
  17.    begin
  18.       Put("Mata in antalet timmar: ");
  19.       Get(A.H1);
  20.       Put("Mata in antalet minuter: ");
  21.       Get(A.M1);
  22.    end Gettid1;
  23.    
  24.    procedure Gettid2(B : out Tid2_Type) is
  25.    begin
  26.       Put("Mata in antalet timmar: ");
  27.       Get(B.H2);
  28.       Put("Mata in antalet minuter: ");
  29.       Get(B.M2);
  30.    end Gettid2;
  31.    
  32.    function "+" (A : in Tid1_Type; B : in Tid2_Type) return character is
  33.       Summa:Integer;
  34.       Summa2:Integer;
  35.      
  36.    begin
  37.      
  38.      
  39.       Summa:= A.H1 + B.H2;
  40.       Summa2:= A.M1 + B.M2;
  41.       if Summa2 > 59 then
  42.        Summa2:= Summa2-60;
  43.        Summa:= Summa+1;
  44.       end if;
  45.       Put(Summa,Width=>1);
  46.       Put(":");
  47.       if Summa2 < 10 then
  48.      Put("0");
  49.      Put(Summa2,Width=>1);
  50.       else
  51.      Put(Summa2,Width=>2);
  52.       end if;
  53.          
  54.      
  55.            
  56.       return ' ' ;
  57.      
  58.      
  59.       end "+";
  60.          
  61.    
  62.    
  63.    A:Tid1_Type;
  64.    B:Tid2_Type;
  65.      
  66. begin
  67.    Put("För den första tiden");
  68.    New_Line;
  69.    Gettid1(A);
  70.    Put("För den andra tiden");
  71.    New_Line;
  72.    Gettid2(B);
  73.    New_Line;
  74.    Put("Total tiden blev ");
  75.    Put("+"(A,B));
  76.    
  77.    
  78.    
  79.    
  80.    end Tider;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement