Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please Help (Pascal)

johnterryjohnterry Member Posts: 1
[b][red]This message was edited by johnterry at 2007-2-26 8:6:16[/red][/b][hr]
You are required to design, code and test a program that can be used to work with a set of 10 positive or negative whole numbers in the range +100 to -100. The program should accept the 10 numbers entered by the user and keep three running totals. The first is the sum of all the numbers entered.. The second is the sum of all the positive numbers entered. The third is the sum of all the negative numbers entered.

Once all 10 numbers have been entered, the program should display its 3 totals to the user.

Your program should check the numbers entered to ensure that they are in range, i.e. -200 would not be accepted but is not required to check that the values entered are of the right type i.e. values such as 1.2 or hello will crash your program, you do not need to try to deal with them.


The above is what i need elp with, im finding this really difficult and was wondering if you guys could help.

I need to know what sort of loops i shoudl be using and how to start it off any help will be greatly apprecitaed thank you


Comments

  • zibadianzibadian Member Posts: 6,349
    : [b][red]This message was edited by johnterry at 2007-2-26 8:6:16[/red][/b][hr]
    : You are required to design, code and test a program that can be used to work with a set of 10 positive or negative whole numbers in the range +100 to -100. The program should accept the 10 numbers entered by the user and keep three running totals. The first is the sum of all the numbers entered.. The second is the sum of all the positive numbers entered. The third is the sum of all the negative numbers entered.
    :
    : Once all 10 numbers have been entered, the program should display its 3 totals to the user.
    :
    : Your program should check the numbers entered to ensure that they are in range, i.e. -200 would not be accepted but is not required to check that the values entered are of the right type i.e. values such as 1.2 or hello will crash your program, you do not need to try to deal with them.
    :
    :
    : The above is what i need elp with, im finding this really difficult and was wondering if you guys could help.
    :
    : I need to know what sort of loops i shoudl be using and how to start it off any help will be greatly apprecitaed thank you
    :
    :
    :
    I would use a for-do loop for this. Here's the basic program code:
    [code]
    var
    i: integer;
    TotalSum, PosSum, NegSum: integer;
    Number: integer;
    begin
    TotalSum := 0;
    // Other initialization code
    for i := 1 to 10 do
    begin
    // User enters number
    // Add number to TotalSum
    if Number < 0 then
    // Add number to NegSum
    else if Number > 0 then
    // Add number to PosSum
    end;
    // Display sums
    end.
    [/code]
    I left several parts for you to code as indicated. These should not be too difficult to code.
Sign In or Register to comment.