Here is the update:
Code:
{Creator - NAME HIDDEN - 7.03.05}
Program Carpet_Calculator(Input,Output);
USES Wincrt;
CONST
Vat_Rate = 0.175; {This is the vat that has to be added to the total price}
Adjustment = 0.1;
VAR
length, Width, Area, TotalCost, Discount, TotalCost_Inc_Discount, Vat,
Total_Cost_plus_VAT, PricePerMetre, phonenumber : Real;
fitting : char;
Begin
Writeln('--------------------------------------------------< by: NAME HIDDEN >---');
Writeln(' Carpet Warehouse ');
Writeln('------------------------------------------------------------------------');
REPEAT {Loop until requirement met}
Write('Enter the required length (M)?: '); {Enter the length of the carpet}
Readln(length);
IF length=0 THEN {If statement begins. If length=0 then begin next code}
Begin
Writeln('Length Cannot be 0. Please try again'); {If length was 0 then it will display this comment and loop
back to Accept Length}
End;
UNTIL length>0 ; {This is requirement of Loop. When met, the loop is broken
and next code can begin}
Begin
REPEAT {Loop until requirement met}
Write('Enter the required Width? (M)?: '); {Enter the Width of the carpet}
Readln(Width);
IF width=0 THEN {If statement begins. If width=0 then begin next code}
Begin
Writeln('Width cannot be 0. Please Try again'); {If width was 0 then it will display this comment and loop
back to Accept Width}
End;
UNTIL width>0 ; {This is requirement of Loop. When met, the loop is broken
and the next code can begin}
Begin
Length:= length + Adjustment; {Adjustment is 0.1 to take into
account sloping walls}
Width:= Width + Adjustment;
END;
REPEAT {Loop until requirement met}
Write('Enter the Price Per Metre?:');
Readln(PricePerMetre);
IF pricepermetre=0 THEN {If price per metre is 0 then begin next perform next code}
Begin
Writeln('Cannot Be £0. Please try again...'); {If price per metre was 0 then write this comment and loop
back to Accept price per metre}
End;
Until PricePerMetre>0 ; {If price per metre is higher than 0 then requirement is met
and loop is broken and the next code can begin}
Begin
Area:= Length * Width; {To work out the area}
Writeln('The area is :',Area:5:2);
TotalCost:= Area * PricePerMetre; {To work out the cost of the carpet for the
specified measurements}
writeln('Cost of Carpet is: £',totalcost:5:2);
{Discount}
IF PricePerMetre > 15 THEN {IF Statement starts here}
{If the Price per metre is higher than 15,
then it will perform code below "begin"}
Begin
Discount:= (TotalCost * (10/100)); {Work out 10% of the total cost}
Writeln('Discount Amount is £',Discount:5:2);
TotalCost_Inc_Discount:= TotalCost - Discount; {total cost - 10% of total cost}
totalCost:= TotalCost_Inc_Discount;
Writeln('Total Cost Including Discount is £',TotalCost:5:2);
end; {IF Statement Ends}
{VAT}
VAT:= TotalCost * VAT_Rate; {to work out VAT of total cost, VAT is
0.175}
Writeln('Vat Amount is: £',Vat:5:2);
Total_Cost_plus_VAT:= TotalCost + VAT; {total cost + VAT will equal
total_cost_plus_VAT}
Writeln('Total Cost Including VAT: £', Total_Cost_plus_VAT:5:2);
writeln;
write('Would you like your carpet fitted? (Y or N): ');
readln(fitting);
If fitting = 'Y' then {If statement starts here}
Begin
totalCost:=Total_Cost_plus_VAT +30;
writeln('An Extra £30 will be added: £ ',totalcost:5:2);
end
else
If fitting = 'y' then {If statement starts here}
begin
totalCost:=Total_Cost_plus_VAT +30;
writeln('An Extra £30 will be added. The final price is: £',totalcost:5:2);
end
else
writeln('No Fitting required...');
BEGIN
writeln('Enter Customer Phone Number:');
readln(phonenumber);
end;
end;
end;
end.
I have to make it work so taht the price per metre will not accept 0 or >50
I have got it to work with anything above 0. But not 50. How do I add that feature along with the current no 0 policy? Also, why do I have to have so many
"end;" on the last part of the code? It doesn't run otherwise, it keeps giving an "error 85 code: ; expected". thanks
Bookmarks