C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Bartleby Related Questions Icon

Related questions

Question

PYTHON 

2. Write a program that sums up all positive user input numbers.
a) For every iteration output the sum of all positive input values.
b) Implement the loop to stop if a negative value is entered.
c) The sentinel value, the negative number should not be included in the sum.
d) Use a function, sumInput() to calculate the sum and return the list that contains all the input numbers.
e) Call the function and print out the list.
Output Example:
Enter a positive number to sum or enter any negative number to end the program: 8.5
Sum = 8.5
Enter a positive number to sum or enter any negative number to end the program: 7
Sum = 15.5
Enter a positive number to sum or enter any negative number to end the program: 100
Sum = 115.5
Enter a positive number to sum or enter any negative number to end the program: -1
All the numbers: [8.5, 7, 100]
Ending Program.
expand button
Transcribed Image Text:2. Write a program that sums up all positive user input numbers. a) For every iteration output the sum of all positive input values. b) Implement the loop to stop if a negative value is entered. c) The sentinel value, the negative number should not be included in the sum. d) Use a function, sumInput() to calculate the sum and return the list that contains all the input numbers. e) Call the function and print out the list. Output Example: Enter a positive number to sum or enter any negative number to end the program: 8.5 Sum = 8.5 Enter a positive number to sum or enter any negative number to end the program: 7 Sum = 15.5 Enter a positive number to sum or enter any negative number to end the program: 100 Sum = 115.5 Enter a positive number to sum or enter any negative number to end the program: -1 All the numbers: [8.5, 7, 100] Ending Program.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning