begin write('Z = '); read(salary); write('K = '); read(payment); write('P = '); read(percent); write('A = '); read(max); balance := 0; gain := 0; for i := 1 to 12 do begin balance := balance + salary - payment; profit := balance * percent / 100; balance := balance + profit; gain := gain + profit; if gain > max then break; end; writeln(gain); end.
Answers & Comments
salary, payment, percent, max, balance, profit, gain: real;
i: integer;
begin
write('Z = ');
read(salary);
write('K = ');
read(payment);
write('P = ');
read(percent);
write('A = ');
read(max);
balance := 0;
gain := 0;
for i := 1 to 12 do
begin
balance := balance + salary - payment;
profit := balance * percent / 100;
balance := balance + profit;
gain := gain + profit;
if gain > max then break;
end;
writeln(gain);
end.