Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Recommended Textbook for

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions