-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject2.dpr
57 lines (50 loc) · 1.16 KB
/
project2.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var category, color, v :longint;
var R, G, B : shortint;
var price: real;
function calc_price(price:real; category:longint):real;
begin
calc_price :=0;
case category of
1: calc_price := price * (1 + 0.10);
2: calc_price := price * (1 + 0.15);
3: calc_price := price * (1 + 0.21);
end;
end;
function decimalToBinary(a:LongInt):String;
var d:Integer;
str:String;
Begin
str:='';
while a>0 do begin
d:=a mod 2;
str:=concat(IntToStr(d),str);
a:=a div 2;
end;
decimalToBinary:=str;
End;
function pixel_color(r, g, b:byte):longint;
begin
pixel_color := r + g shl 8 + b shl 16;
end;
procedure to_colors(color:longint);
begin
writeln(color and 255);
writeln((color shr 8) and 255);
writeln((color shr 16) and 255);
end;
begin
to_colors( pixel_color(2, 3, 255));
writeln('price of product');
readln(price);
writeln('category of product (1 - 10%;2 - 15%;3 - 21%)');
readln(category);
write('price after tax: ');
writeln(calc_price(price, category):0:2);
writeln(decimalToBinary( pixel_color(2, 3, 255)));
writeln('for terminate program press enter...');
readln;
end.