Hello,
I am a beginner in Pascal.
I was wondering if anyone could tell me what is wrong with the following code:

The error message says that ; expected but else found, when there is a semi colon before else.

Program first (input, output);


var
discount,
price,
total:real;
sale:char;

begin
write ('Enter the regular price: ');
readln (price);
write ('On Sale?: ');
readln (sale);

discount:= price/4;
total:= price + discount;

if (sale= 'y') or (sale= 'Y')
then
begin
gotoxy (1,5);
writeln ('Discount: ');
gotoxy (1,7);
writeln ('Total: ');
gotoxy (30,5);
writeln ('$',discount:3:2);
gotoxy (30,7);
writeln ('$',total:3:2)
end;
else if (sale = 'n') or (sale= 'N')
then writeln ('Total: ', price);
readln;

end.

Ok, sorry. This was originally a procedure for a menu, so I quickly copied and pasted without putting uses crt; and forgetting several vital components.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.