Advertisement
193030

Zapisi, 06

Dec 10th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.89 KB | None | 0 0
  1. type
  2.     typeProduct = record
  3.         name : string[10];
  4.         yearMade, bestTo : integer;
  5.         price : array[1..2] of real;
  6.         end;
  7. var
  8.     notValidProducts : array[1..10] of integer;
  9.     product : array[1..10] of typeProduct;
  10.     numberOfProductMinPrice, notValidProductsNumber, i : integer;
  11.     minimumPrice : real;
  12.  
  13. procedure LoadData;
  14. begin
  15.     product[1].name:='Tomato';
  16.     product[1].yearMade:=2020;
  17.     product[1].bestTo := 2021;
  18.     product[1].price[1]:=10.20;
  19.     product[1].price[2]:=12.20;
  20.  
  21.     product[2].name:='banana';
  22.     product[2].yearMade:=2020;
  23.     product[2].bestTo := 2016;
  24.     product[2].price[1]:=110.20;
  25.     product[2].price[2]:=122.20;
  26.    
  27.     product[3].name:='Carrot';
  28.     product[3].yearMade:=2018;
  29.     product[3].bestTo := 2018;
  30.     product[3].price[1]:=44.20;
  31.     product[3].price[2]:=55.20;
  32. end;
  33.  
  34. procedure Output;
  35. begin
  36.     writeln('The product with minimal price is: ', product[numberOfProductMinPrice].name, ', and the price is: ',product[numberOfProductMinPrice].price[1]:5:2);
  37.     notValidProductsNumber:=notValidProductsNumber-1;
  38.     writeln('There are: ', notValidProductsNumber, ' products which are not valid');
  39.     for i:=1 to notValidProductsNumber do
  40.         begin
  41.          writeln('The the product which is not valid is: ', product[notValidProducts[i]].name);
  42.         end;
  43.  
  44. end;
  45.  
  46.  
  47. procedure ValidProductCheck;
  48. begin
  49.   notValidProductsNumber:=1;
  50.   for i:=1 to 3 do with product[i] do
  51.    begin
  52.    if 2019>bestTo then
  53.     begin
  54.       notValidProducts[notValidProductsNumber]:= i;
  55.       notValidProductsNumber:=notValidProductsNumber+1;
  56.     end;
  57.     end;
  58. end;
  59.  
  60.  
  61. procedure LowestPrice;
  62. var
  63. i, j : integer;
  64. begin
  65.     minimumPrice:=1000;
  66.     for i:=1 to 3 do with product[i] do
  67.      begin
  68.         if price[1] < minimumPrice then
  69.          begin
  70.             minimumPrice :=price[1];
  71.             numberOfProductMinPrice:= i;
  72.          end;
  73. end;
  74. end;
  75.  
  76. BEGIN
  77.     LoadData;
  78.     LowestPrice;
  79.     ValidProductCheck;
  80.     Output;
  81.     readln();
  82.  
  83. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement