: : : I am writeing a program for my uncle how is a builder! the first thing iam doing is a room with 4 sides like a cube or rectangle, finding the area of each side then asking if there are any windows. this is were my problem comes in,
: : :
: : : for loop := 1 to NumWin do
: : : begin
: : : write(' enter the length of window ', loop,': ');
: : : readln(lengthW1);
: : : write(' enter the breadth of window ', loop,': ');
: : : readln(breadthW1);
: : :
: : : totalAreaW := lengthW1 * breadthW1;
: : : write(totalAreaW);
: : :
: : : end;
: : :
: : : my problem is that when I call the totalAreaW1 for each window I dont know how to add them all together. I can do the calculation but it will only add one of the turns! how can I do this?
: :
: :
: : totalAreaW := 0;
: : for loop := 1 to NumWin do
: : begin
: : write(' enter the length of window ', loop,': ');
: : readln(lengthW1);
: : write(' enter the breadth of window ', loop,': ');
: : readln(breadthW1);
: :
: : totalAreaW := totalAreaW + (lengthW1 * breadthW1);
: : end;
: : write(totalAreaW);
: :
: :
:
: but if the user types in 2 windows, it calculates area of window1 and window2, but when It comes to add these together it just calculets window2.
:
: thanks
:
: Sweeney
Notice the changes I made (In Bold). These will calculate them into one variable that contains the total area of the windows. It doesn't overwrite the first value, just adds it on to the first one.
Phat Nat
PS- Try it. Two windows, each 4'x4' should have an area of 2*4'*4' = 2*64 sqft = 128 sqft. (64 each, 128 together)