## Pascal

Moderators: None (Apply to moderate this forum)
Number of posts: 14016

This Forum Only

Re: Beginners help please. Posted by goosh on 8 Mar 2003 at 10:11 AM
: : 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);
: : 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 :)

goosh Beginners help please. on 7 Mar 2003 at 4:38 AM
Perran Re: Beginners help please. on 7 Mar 2003 at 5:14 AM
goosh Re: Beginners help please. on 8 Mar 2003 at 10:11 AM
goosh Re: Beginners help please. on 10 Mar 2003 at 11:26 AM
Perran Re: Beginners help please. on 11 Mar 2003 at 4:02 AM

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic