Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- typeProduct = record
- name : string[10];
- yearMade, bestTo : integer;
- price : array[1..2] of real;
- end;
- var
- notValidProducts : array[1..10] of integer;
- product : array[1..10] of typeProduct;
- numberOfProductMinPrice, notValidProductsNumber, i : integer;
- minimumPrice : real;
- procedure LoadData;
- begin
- product[1].name:='Tomato';
- product[1].yearMade:=2020;
- product[1].bestTo := 2021;
- product[1].price[1]:=10.20;
- product[1].price[2]:=12.20;
- product[2].name:='banana';
- product[2].yearMade:=2020;
- product[2].bestTo := 2016;
- product[2].price[1]:=110.20;
- product[2].price[2]:=122.20;
- product[3].name:='Carrot';
- product[3].yearMade:=2018;
- product[3].bestTo := 2018;
- product[3].price[1]:=44.20;
- product[3].price[2]:=55.20;
- end;
- procedure Output;
- begin
- writeln('The product with minimal price is: ', product[numberOfProductMinPrice].name, ', and the price is: ',product[numberOfProductMinPrice].price[1]:5:2);
- notValidProductsNumber:=notValidProductsNumber-1;
- writeln('There are: ', notValidProductsNumber, ' products which are not valid');
- for i:=1 to notValidProductsNumber do
- begin
- writeln('The the product which is not valid is: ', product[notValidProducts[i]].name);
- end;
- end;
- procedure ValidProductCheck;
- begin
- notValidProductsNumber:=1;
- for i:=1 to 3 do with product[i] do
- begin
- if 2019>bestTo then
- begin
- notValidProducts[notValidProductsNumber]:= i;
- notValidProductsNumber:=notValidProductsNumber+1;
- end;
- end;
- end;
- procedure LowestPrice;
- var
- i, j : integer;
- begin
- minimumPrice:=1000;
- for i:=1 to 3 do with product[i] do
- begin
- if price[1] < minimumPrice then
- begin
- minimumPrice :=price[1];
- numberOfProductMinPrice:= i;
- end;
- end;
- end;
- BEGIN
- LoadData;
- LowestPrice;
- ValidProductCheck;
- Output;
- readln();
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement