Question

C++ Programming Help Please! NOTE: Please READ All Steps very carefully. DO #10! (10 is based...

C++ Programming Help Please!

NOTE: Please READ All Steps very carefully. DO #10! (10 is based off of 9).

Program Info:  

#9. Write a program that reads in ten whole numbers and that outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the ten numbers just once each and the user can enter them in any order. Your program should not ask the user to enter the positive numbers and the negative numbers separately. 10. Modify your program from Programming Project 9 so that it outputs the sum of all positive numbers, the average of all positive numbers, the sum of all nonpositive numbers, the average of all nonpositive numbers, the sum of all positive and nonpositive numbers, and the average of all numbers entered.

#10. Modify your program from Programming ***Project 9*** so that it outputs the sum of all positive numbers, the average of all positive numbers, the sum of all nonpositive numbers, the average of all nonpositive numbers, the sum of all positive and nonpositive numbers, and the average of all numbers entered.

More Important Info:

You will need a counting loop that goes from 0 to 10.

Inside the loop, separate the positive and negative numbers using an if/else

maintain the total of the positive and negative numbers in the if/else

maintain the grand total in the body of the loop.

outside the loop, print the report of the total of the positive, negative and the grand total.

You should also count the number of the positive and negative numbers and print it at the end.

Document like your life depends on it!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

9- #include<iostream>
using namespace std;
int main()
{
int arr[10];
int sum1=0,sum2=0,sum3=0;
cout<<"Enter 10 whole numbers - ";
for(int i=0;i<10;i++)
cin>>arr[i];
for(int i=0;i<10;i++)
{if(arr[i]>0)
sum1+=arr[i];
else
sum2+=arr[i];
}
sum3=sum1+sum2;
cout<<"Sum of positive numbers : "<<sum1;
cout<<"\nSum of numbers less then or equal to 0 : "<<sum2;
cout<<"\nSum of all numbers : "<<sum3;
}

10-

#include<iostream>

using namespace std;

int main()

{

int arr[10];

int sum1=0,sum2=0,sum3=0,c1=0,c2=0;

float avg1,avg2,avg3;

cout<<"Enter 10 whole numbers - ";

for(int i=0;i<10;i++)

cin>>arr[i];

for(int i=0;i<10;i++)

{if(arr[i]>0){

++c1;

sum1+=arr[i];

}

else{

++c2;

sum2+=arr[i];

}

}

sum3=sum1+sum2;

avg1=(float)sum1/c1;

avg2=(float)sum2/c2;

avg3=(float)sum3/10;

cout<<"Sum of positive numbers : "<<sum1;

cout<<"\nAverge of positive numbers : "<<avg1;

cout<<"\nSum of numbers less then or equal to 0 : "<<sum2;

cout<<"\nAverage of numbers less then or equal to 0 : "<<avg2;

cout<<"\nSum of all numbers : "<<sum3;

cout<<"\nAvergae of all numbers : "<<avg3;

}

Add a comment
Know the answer?
Add Answer to:
C++ Programming Help Please! NOTE: Please READ All Steps very carefully. DO #10! (10 is based...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer using programming in C only. 6 pts Use a while loop to complete the following:...

    Answer using programming in C only. 6 pts Use a while loop to complete the following: Prompt the user to enter integers one by one, until the user enters a negative number to stop Calculate the sum and the average of all the numbers entered by the user Print the sum and the average onto the screen after the loop. Declare and initialize all variables. Be sure to keep a count of the numbers entered for the average calculation

  • 1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The...

    1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...

  • use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times)...

    use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times) Outputs: • [integer) highest value . [integer] lowest value Description: Write a program that lets the user enter 10 values. These values should be stored in an array. Your program will then find the highest and lowest values in the array. Your program will display the list of number as a comma separated list, and print which values is the highest and lowest Do...

  • Write a program that calculates the average of a stream of non-negative numbers. The user can...

    Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they want, and they will indicate that they are finished by entering a negative number. For this program, zero counts as a number that goes into the average. Of course, the negative number should not be part of the average (and, for this program, the average of 0 numbers is 0). You must use a method to read...

  • Hi please help me with this zybooks question asap. Thanks 4.17 Chapter 4 Program: Sum of...

    Hi please help me with this zybooks question asap. Thanks 4.17 Chapter 4 Program: Sum of Numbers/C++ program Write a C ++ program that asks the user for a positive integer value by prompting "Enter a positive integer number: ", read in that number, then use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2,3, 4…50....

  • C++ Quesetion In this exercise, you are to modify the Classify Numbers programming example in this...

    C++ Quesetion In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard input device (keyboard) and outputs the results on the standard output device (screen). The program can process only 20 numbers. Rewrite the program to incorporate the following requirements: a. Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many...

  • need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that...

    need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...

  • please help part one) Calories Burned Running on a particular-treadmill you burn 3.9 calories per minute....

    please help part one) Calories Burned Running on a particular-treadmill you burn 3.9 calories per minute. Design a pro- gram that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes. 3 part two) Sum of Numbers Design a program with a loop that asks the user to enter a series of positive num bers. The user should enter a negative number to signal the end of the series. After all the...

  • Please write the code in assembly language which can run in HLA. Thank you very much!!...

    Please write the code in assembly language which can run in HLA. Thank you very much!! -So we need to write the code in assembly language in Notepad++, end with .hla and run it in CMD. - This project is about writing a program to read numbers, counts the items read, calculates the total, the maximum and minimum of the numbers. -The program stops when a 0 is entered. Zero will not be part of the data. -work with integers,...

  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT