Code a decision using an IF, THEN, ELSE statement (2 branch decision)
Code a one branch decision using a null else statement
The following is my answer:
program Negatives;
{$APPTYPE CONSOLE}
uses
SysUtils,
ourcrt;
var
balance, posNeg:integer;
begin
randomize;
writeln ('Generating your bank balance');
writeln ('Please wait .....');
sleep (2000);
//create a random number between 0 and 1000
balance:=random(1000);
//randomly decide if the balance is negative
//1 for positive, 0 for negative
posNeg:=random(2);
if posNeg=0 then
begin
balance:=balance*-1;
writeln('Can you hear that sound? Its your cheque bouncing');
sound(200,1000);
end
else
begin
writeln ('Positive balance');
end;
writeln('Your balance is ', balance);
sleep(5000);
end.
Could you tell me why at the Line 22 & 25, we do not want to put full-stop / semi-colon after the 'end'? It makes me very confused about the punctuation marks.