Board index » delphi » Can any one help with turbo pascal?

Can any one help with turbo pascal?

Hello
I have done this little program to calculate how many rolls of wall paper to
use when decorating but I am missing something as the program runs but
crashes after I input the info????
any ideas
many thanks

program estimates;
uses wincrt;
var
   length:real;
   height:real;
   width:real;
   paper_width, paper_length   :real;
   wall_area, no_of_rolls, roll_area      :real;

begin
   {enter dimensions of wall and wallpaper roll}
   write('enter the length of the wall: ');
   readln(length);
   write('enter the higth of the wall: ');
   readln(height);

   write('enter the width of the roll: ');
   readln(width);

   {calculate number of rolls required}
   wall_area:=length*height;
   roll_area:=paper_width*paper_length;
   no_of_rolls:=wall_area/roll_area;
   no_of_rolls:=1.10*no_of_rolls;

   writeln('you will need ',no_of_rolls:6:1,' rolls of wallpaper')
end.

 

Re:Can any one help with turbo pascal?


Quote
Wilfys wrote:

> Hello
> I have done this little program to calculate how many rolls of wall paper to
> use when decorating but I am missing something as the program runs but
> crashes after I input the info????
> any ideas
> many thanks

> program estimates;
> uses wincrt;
> var
>    length:real;
>    height:real;
>    width:real;
>    paper_width, paper_length   :real;
>    wall_area, no_of_rolls, roll_area      :real;

> begin
>    {enter dimensions of wall and wallpaper roll}
>    write('enter the length of the wall: ');
>    readln(length);
>    write('enter the higth of the wall: ');
>    readln(height);

>    write('enter the width of the roll: ');
>    readln(width);

>    {calculate number of rolls required}
>    wall_area:=length*height;
>    roll_area:=paper_width*paper_length;

If paper_length is 0.0 at this point --

Quote
>    no_of_rolls:=wall_area/roll_area;

This will give a fatal divide by zero error.

Quote
>    no_of_rolls:=1.10*no_of_rolls;

>    writeln('you will need ',no_of_rolls:6:1,' rolls of wallpaper')
> end.

And I notice you never initialized paper_length.

Hope this helps

Al Moore

Re:Can any one help with turbo pascal?


Quote
Wilfys wrote:
> program estimates;
> uses wincrt;
> var
>    length:real;
>    height:real;
>    width:real;
>    paper_width, paper_length   :real;
>    wall_area, no_of_rolls, roll_area      :real;

> begin
>    {enter dimensions of wall and wallpaper roll}
>    write('enter the length of the wall: ');
>    readln(length);
>    write('enter the higth of the wall: ');
>    readln(height);

>    write('enter the width of the roll: ');
>    readln(width);

>    {calculate number of rolls required}
>    wall_area:=length*height;
>    roll_area:=paper_width*paper_length;

paper_width and paper_length are both 0, so roll_area is 0.

Quote
>    no_of_rolls:=wall_area/roll_area;

roll_area is 0, so this division fails.

Re:Can any one help with turbo pascal?


On Mon, 22 Jan 2001 20:38:43 -0000, "Wilfys" <Wil...@hotmail.com>
wrote:

Quote
>Hello
>I have done this little program to calculate how many rolls of wall paper to
>use when decorating but I am missing something as the program runs but
>crashes after I input the info????
>any ideas
>many thanks

...............snip.............

Since you have already received good advice on your program, here is
some practical advice about wallpaper. Many patterns are a "drop
match" which means the pattern that repeats is offset from the left to
the right side of the roll. In a large room, this may result in
significant s{*word*99}s.

Re:Can any one help with turbo pascal?


Quote
"Clif Penn" <clifp...@airmail.net> wrote in message

news:FA36045FB6AFAB80.DB1ADB6845D9FB25.92D652EC0E140CAF@lp.airnews.net
...

Quote
> On Mon, 22 Jan 2001 20:38:43 -0000, "Wilfys" <Wil...@hotmail.com>
> wrote:

> >Hello
> >I have done this little program to calculate how many rolls of wall
paper to
> >use when decorating but I am missing something as the program runs
but
> >crashes after I input the info????
> >any ideas
> >many thanks
> ...............snip.............

> Since you have already received good advice on your program, here is
> some practical advice about wallpaper. Many patterns are a "drop
> match" which means the pattern that repeats is offset from the left
to
> the right side of the roll. In a large room, this may result in
> significant s{*word*99}s.

No kidding. On a small room too, if you're not careful. I got 7 rolls
for my bedroom, thinking it would be good to get 1 or 2 too many, just
in case. Now I have 3 rolls with enough paper to get from the floor to
within half a meter of the ceiling, useless. The roll goes a bit over
4 times the height of the room, so nearly a quarter of each roll was
wasted, because of such s{*word*99}s.

After the 3rd roll, I realised that this couldn't go on; then I
figured out that using 2 rolls at a time I could lose less than half a
drop each time I hung a page, instead of almost a full drop, meaning I
get an extra page out of each roll. Should have thought of it earlier,
that's what I get for putting up wallpaper at 3am.

FP

Re:Can any one help with turbo pascal?


JRS:  In article <FA36045FB6AFAB80.DB1ADB6845D9FB25.92D652EC0E140CAF@lp.
airnews.net>, seen in news:comp.lang.pascal.borland, Clif Penn
<clifp...@airmail.net> wrote at Tue, 23 Jan 2001 10:51:59 :-

Quote

>Since you have already received good advice on your program, here is
>some practical advice about wallpaper. Many patterns are a "drop
>match" which means the pattern that repeats is offset from the left to
>the right side of the roll. In a large room, this may result in
>significant s{*word*99}s.

One evidently needs to measure down each roll, first, to a particular
point on the pattern, and also measure the drop; and then write a little
Pascal program to select the best of the N! orders for N rolls.  With
allowance, of course, if one wants the top or bottom of the wall to be
at a particular phase of the pattern.

As a further programming exercise, s{*word*99}s may be used if there are
locations for the joints which Top Management will not notice.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Other Threads