troubleshooting Question

Pascal looping prgram

Avatar of ffreds
ffreds asked on
Pascal
22 Comments1 Solution522 ViewsLast Modified:
I need to write a Pascal program that keeps a few statistics on the programs' input.
The program needs to input real numbers from the keyboard, one at a time, until the
number typed in is zero.  At that time, I need it to show the final results.  During the input
process, it needs to track how many items are positive and how many are negative, and add the input
value to an appropriate running total.  When the loop is overwith, it needs to print the following:

There were 5 positive values, average 17.2
There were 2 negative values, average -8.7

If the number of positive or negative values is zero, don't compute or print the average.

Example run:

Type value: 17
Type value: -8
Type value: 21
Type value:  0

There were 2 positive values, average  19.0
There were 1 negative values, average  -8.0

This is what I have so far but its not working,

var
number,PosSum,PosNumebrCount,NegSum,NegNumebrCount: integer;
begin
 repeat
    write('Enter a number (0 to quit): '); readln(Number);
    { Calculations, see later }
  until Number = 0;


  if Number > 0 then
    begin
      PosSum := PosSum + Number;
      PosNumebrCount := PosNumebrCount + 1;
    end else if Number < 0 then begin
      { negative left to you }
    end;

  if Number < 0 then
  begin
      NegSum := NegSum + Number;

      NegNumebrCount := NegNumebrCount + 1;
      end else if Number < 0 then begin
      end;
end.

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros