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.
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.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 8PE
Related questions
Question
PYTHON
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning