Question
C++ Count positive and negative numbers and compute the average of numbers (Required) Write a program that prompts the user to enter the number of
C++
Count positive and negative numbers and compute the average of numbers (Required)
Write a program that prompts the user to enter the number of integers to read. Your program should do the following things:
Read the values using a while loop.
Determine the numbers entered positive or negative.
Count how many positive and negative values have been read.
Outputs the sum of all the numbers that are greater than zero, the sum of all the numbers less than zero, and the sum of all the numbers, whether positive, negative, or zero.
Calculate the average of all the numbers. Display the average as a floating-point number (three digits after the decimal point).
Your program should not ask the user to enter the positive numbers and the negative numbers separately. Allow the user to repeat as many times as they would like before ending the program.
Here is the sample run:
Enter the number of integers: 5
Enter values: 1 2 -1 -3 9
The number of positive numbers is 3
The number of negative numbers is 2
The sum of all positive numbers is 12
The sum of all negative numbers is -4
The total is 8
The average is 1.600
Would you like to repeat (Y or N): Y
Enter the number of integers: 10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started