Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers,

Use C++

Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally 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 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.

The result should look exactly like:

-bash-4.3$ ./sum How many numbers will you enter? 6 Enter 6 whole numbers while I count down. Entries left to go: 6 19 Entries left to go: 5 -4 Entries left to go: 4 0 Entries left to go: 3 -6 Entries left to go: 2 3 Entries left to go: 1 -4 The sum of 2 numbers greater than zero is 22. The sum of 3 numbers less than zero is -14. The sum of all 6 numbers is 8. Goodbye. 

If the user enters 0 or less in response to the first question, instead of executing the rest, the program simply must print "There is nothing to sum."

How many numbers will you enter? 0 There is nothing to sum. Goodbye. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions