Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO;use Ada.Text_IO;
- with Ada.Integer_Text_IO;use Ada.Integer_Text_IO;
- procedure Tider is
- type Tid1_type is record
- H1:Integer;
- M1:Integer;
- end record;
- type Tid2_type is record
- H2:Integer;
- M2:Integer;
- end record;
- procedure GetTid1(A : out Tid1_Type) is
- begin
- Put("Mata in antalet timmar: ");
- Get(A.H1);
- Put("Mata in antalet minuter: ");
- Get(A.M1);
- end Gettid1;
- procedure Gettid2(B : out Tid2_Type) is
- begin
- Put("Mata in antalet timmar: ");
- Get(B.H2);
- Put("Mata in antalet minuter: ");
- Get(B.M2);
- end Gettid2;
- function "+" (A : in Tid1_Type; B : in Tid2_Type) return character is
- Summa:Integer;
- Summa2:Integer;
- begin
- Summa:= A.H1 + B.H2;
- Summa2:= A.M1 + B.M2;
- if Summa2 > 59 then
- Summa2:= Summa2-60;
- Summa:= Summa+1;
- end if;
- Put(Summa,Width=>1);
- Put(":");
- if Summa2 < 10 then
- Put("0");
- Put(Summa2,Width=>1);
- else
- Put(Summa2,Width=>2);
- end if;
- return ' ' ;
- end "+";
- A:Tid1_Type;
- B:Tid2_Type;
- begin
- Put("För den första tiden");
- New_Line;
- Gettid1(A);
- Put("För den andra tiden");
- New_Line;
- Gettid2(B);
- New_Line;
- Put("Total tiden blev ");
- Put("+"(A,B));
- end Tider;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement