95.1k views
2 votes
Create a Raptor program. For a list of numbers entered by the user and terminated by 0. Write a Raptor program to find the sum of ALL the positive numbers and the sum of ALL the negative numbers. The Raptor program will contain a loop that will run as long as the number entered by the user is not 0. If the entered number is not 0, the program will determine if the number is positive or negative and add the value of the number into an accumulator variable. When the user enters 0, the program will exit the loop and output the values for the positive and negative accumulator variables.

1 Answer

4 votes

Final answer:

To create a Raptor program that finds the sum of positive and negative numbers entered by the user, you'll need to use a loop to continue reading numbers until the user enters 0. Within the loop, you can check if the number is positive or negative and add it to the respective accumulator variable.

Step-by-step explanation:

To create a Raptor program that finds the sum of positive and negative numbers entered by the user, you'll need to use a loop to continue reading numbers until the user enters 0. Within the loop, you can check if the number is positive or negative and add it to the respective accumulator variable.

Here's an example of how the Raptor code would look like:

  1. Set the positive accumulator variable to 0.
  2. Set the negative accumulator variable to 0.
  3. Start a loop that continues until the user enters 0.
  4. Read a number from the user.
  5. If the number is greater than 0, add it to the positive accumulator.
  6. If the number is less than 0, add it to the negative accumulator.
  7. Repeat steps 4-6 until the user enters 0.
  8. Output the values of the positive and negative accumulator variables.

Remember to use the correct syntax and logic in your Raptor program. This program will correctly find the sum of positive and negative numbers entered by the user.

User Albert Gareev
by
9.1k points