Question: Sum the floats You are to write a program that uses a while-loop to read in a series of floating point numbers from the user

 Sum the floats You are to write a program that uses

Sum the floats You are to write a program that uses a while-loop to read in a series of floating point numbers from the user via cin. All the numbers entered by the user that are greater than zero you should sum up (add them together.) Once the user enters a number less than zero, your loop should end, you should not add that negative to the number to your sum, and you should print out the sum. For example if the user enters 4.5 2.3-2, your program would print the sum as 6.8 (4.5 2.3). The user can enter an arbitrary amount of numbers. See the sample code below. User input is in bold italics. Sample run 1: Enter value: 1.5 Enter value: 4.32 Enter value: 2.41 Enter value: 9 Enter value: 7.65 Enter value: 4.35 Enter value: 3.21 Enter value: -11 Sum is: 32.44 Sample run 2 Enter value: 4.3 Enter value: 2.5 Enter value: -3 Sum is: 6.8 YOUR ANSWER We recommend you take a quick tour of our editor before you proceed. The timer will pause up to 90 seconds for the tour. Start tour For help on how to read input and write output in C++,click here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!