: : Hi can anyone tell me how to get the region sales to calculete the whole 8 inputs? What it seems is happening is the a integer is repeating untill 8 but that the program stops at 8 and only adds the first 7. If I put repeat untill a > 8 then it still asks for the 9th region although it does calculate the first 8 which is what I want it to do.
: : program regions;
: :
: : var
: :
: : a:integer;
: : region_sales, total_sales:real;
: :
: : procedure init;
: : begin
: : region_sales := 0.0;
: : total_sales := 0.0;
: : a := 0;
: : end;
: :
: : procedure get_sales;
: : begin
: : writeln ('Please enter sales for region ',a);
: : readln (region_sales);
: : end;
: :
: : procedure print_sales;
: : begin
: : writeln ('The sales for all regions were ',total_sales:6:2);
: : end;
: :
: : begin
: : init;
: : repeat
: :
: : a := a + 1;
: : total_sales := total_sales + region_sales;
: : get_sales;
: : until a = 8;
: : print_sales;
: :
: : end.
: :
: : Thanks for any help :)
: :
: : Oh yeah and I tried using the while statement (while total_sales > 9 do) but that keeps asking me for the 9th region before calculating the first 8 too.
: :
: :
: :
: :
: You need to place your call to get_sales before the line that adds the region_sales to the total. HTH
:
Oh that's wild! Thanks for your reply! That works but I can't believe I didn't see that lol. I hope you answer my next question although I do want to learn it myself but my syntax is so bad. Thanks again :)