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
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.
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
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning