F
F
Frel2015-08-24 19:05:56
Pascal
Frel, 2015-08-24 19:05:56

The else statement doesn't work in pascal why?

It says "Program1.pas(21) : 'else' encountered but operator expected"

program test;

var
  sum: real;
  percent: real;
  period: integer;
  
  profit: real;
  result: real;
begin
  writeln('Вычисление дохода по в кладу в банке');
  writeln;
  
  write('Сумма (руб.) ->');
  readln(sum);
  write('Срок вклада (дней) ->');
  readln(period);
  
  if sum > 5000 then
         percent := 0.95;
      else
         pecent := 0.08;
  profit := sum * percent/365 * period;
  result := sum +profit;
  
  writeln('Сумма в конце срока вклады: ',
           result:6:2, руб.');
  writeln('Доход: ', profit:6:2, ' руб.');
  write('Для завершения работы нажмите <Enter>');
  readln;
end.

why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2015-08-24
@saboteur_kiev

How did you determine what wasn't working?
It's not Else that doesn't work for you, but there are a lot of grammatical errors.
No need to put a semicolon after the first
percent := 0.95
in the second pecent := 0.08; you need to write percent and not pecent
in the line
writeln('Amount at the end of the term deposits: ',
result:6:2, rub.');
You are missing a single quote before the rub.
Is it really that hard to be careful?

F
flatcar, 2015-09-09
@flatcar

if sum > 5000 then
percent := 0.95;
else
before 'else' ';' not put

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question