Giammy
Program p1; var n,m,s:real; i:integer; a:array[1..7] of real; begin write('Write n: '); readln(n); write('Write m: '); readln(m); writeln('Enter the weight of things: '); for i:=1 to 7 do read(a[i]);
s:=0; for i:=1 to 6 do s:=s+a[i]; if s>20 then begin s:=(s-20)*n; writeln('For luggage: ',s:0:2); end else writeln('For luggage: ',s:0:2);
if a[7]>5 then begin a[7]:=(a[7]-5)*m; writeln('For hand luggage: ',a[7]:0:2); end else writeln('For hand luggage: ',a[7]:0:2); readln end.
Answers & Comments
var
n,m,s:real;
i:integer;
a:array[1..7] of real;
begin
write('Write n: '); readln(n);
write('Write m: '); readln(m);
writeln('Enter the weight of things: ');
for i:=1 to 7 do
read(a[i]);
s:=0;
for i:=1 to 6 do
s:=s+a[i];
if s>20
then
begin
s:=(s-20)*n;
writeln('For luggage: ',s:0:2);
end
else
writeln('For luggage: ',s:0:2);
if a[7]>5
then
begin
a[7]:=(a[7]-5)*m;
writeln('For hand luggage: ',a[7]:0:2);
end
else
writeln('For hand luggage: ',a[7]:0:2);
readln
end.