Disclaimer - this is a homework assignment. The professor doesn't teach in a manner that I am able to comprehend so am asking for guidance. I have researched and I am not able to find solutions. I do not want this solved for me because then I won't learn it. I am hoping that someone here can explain in a way I understand. I am not a programmer and have never done this before. Please do not slam me for asking for help - just delete if not allowed. Thank you for your help.
The assignment is to write a program using a loop that accepts a maximum of 5 numbers so that it displays the average of the positive and negative numbers.Do not count the number zero as positive or negative.
The output should look like this -
Enter a number - 17
Enter a number - -10
Enter a number - 19
Enter a number - 0
Enter a number - -4
Average of positive numbers - 18
Average of negative numbers - -7
Here is my program so far - My issue is in the if statements. I also don't know how to write code that will separate the neg from pos and add them. I don't know where to look to find the answer.
Oh I get it! The else statement is the "answer" if the if statement isn't true so wouldn't have conditions. That makes sense. Thank you Repeater.
I did the else if () and that is part of what I was trying to do. Thank you adam2016.
I now have the issue of the program running through the for / if / else statements before going back to the for statement. I'm wanting all 5 of the "enter a number" inputs to be completed before going down to the if / else part. Would a nested for statement redirecting the program back to the first for statement work? Or is there better way?
Would someone please direct me to where I can learn how to write the program to recognize the difference between positive and negative numbers? I just need a hint so I can go digging.