0

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.

1
Contributor
1
Reply
2
Views
10 Years
Discussion Span
Last Post by mockba
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.