
лабораторная работа / лабораторные работы по LAZARUS / Отчет спо лазарус лаба 5 вариант 20
.docxЦель работы: изучить записи и создать приложение, в котором используются данные типа запись.
ЗАДАНИЕ: Даны следующие данные: расчетный счет плательщика, расчетный счет получателя, перечисляемая сумма в рублях. Написать программу, выполняющую следующие действия:
-
сортировку по расчетным счетам плательщиков;
-
вывод на экран информации о сумме, снятой с расчетного счета плательщика, введенного с клавиатуры; если такого расчетного счета нет, вывести на экран соответствующее сообщение.
-
вывод на экран информации о плательщиках, которые сняли со своего расчетного счета более 5000 руб.
ЛИСТИНГ ПРОГРАММЫ:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Grids,
Buttons, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
BitBtn1: TBitBtn;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
type
zap=record
name1,name2: string[20];
number: integer;
end;
var
MZap:array[1..6] of zap;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
with StringGrid1 do
begin
Cells[0,0]:='Р/С плательщика';
Cells[1,0]:='Р/С получателя';
Cells[2,0]:='Перечисляемая сумма';
for i:=1 to 6 do Cells[0,i]:=IntToStr(i);
Cells[0,1]:='1'; Cells[1,1]:='101'; Cells[2,1]:='500';
Cells[0,2]:='2'; Cells[1,2]:='102'; Cells[2,2]:='1000';
Cells[0,3]:='3'; Cells[1,3]:='103'; Cells[2,3]:='2000';
Cells[0,4]:='4'; Cells[1,4]:='104'; Cells[2,4]:='3000';
Cells[0,5]:='5'; Cells[1,5]:='105'; Cells[2,5]:='4000';
Cells[0,6]:='6'; Cells[1,6]:='106'; Cells[2,6]:='6000';
for i:=1 to 6 do
with MZap[i] do
begin
name1:=Cells[1,i];
name2:=Cells[2,i];
number:=StrToInt(Cells[0,i]);
Cells[0,i]:=FloatToStr(number);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i,j,a: integer;
buffer: zap;
x: string;
begin
for i:=1 to 5 do
for j:=i+1 to 6 do
if MZap[j].number<MZap[i].number then
begin
buffer:=MZap[i];
MZap[i]:=MZap[j];
MZap[j]:=buffer;
end;
x:=('');
for i:=1 to 6 do
with StringGrid1,MZap[i] do
a:=StrToInt(MZap[i].name2);
if a>5000
then
begin
x:=(''+StringGrid1.Cells[0,i])
end;
Label5.Caption:=x;
for i:=1 to 6 do
with StringGrid1,MZap[i] do
begin
Cells[1,i]:=name1;
Cells[2,i]:=name2;
Cells[0,i]:=FloatToStr(number);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,x,a: integer;
begin
x:=StrToInt(Edit1.Text);
a:=0;
for i:=1 to 6 do
begin
if x=MZap[i].number
then
begin
Label1.Caption:=('Перечисленная сумма:'+#32+StringGrid1.Cells[2,i]);
a:=1
end;
end;
if a<>1
then
begin
MessageDlg('Такого расчетного счета нет в списке', mtInformation, [mbOk], 0)
end;
end;
initialization
{$I unit1.lrs}
end.