Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ programming 1. In a file named sentine|_sum.py, write a program that continuously asks the user to enter a positive integer value. If the user

c++ programming

image text in transcribed
1. In a file named sentine|_sum.py, write a program that continuously asks the user to enter a positive integer value. If the user enters 1, then the program should stop asking the user to enter a number and should instead print the sum of the numbers that the user have already entered. (the 1 should not be included in the sum). Below is a sample run of the program. Enter a positive integer value: 10 Enter a positive integer value: 20 Enter a positive integer value: 30 Enter a positive integer value:: -1 The sum of the numbers you entered is 60. 2. In a file named sentinel_average.py copy and paste the code that you wrote for question #1 above. You should then alter this code so that instead of printing the sum of the postive integers that are entered, you print the average of the numbers entered (except for the -1) Below is a sample run of the program. Enter a positive integer value: 10 Enter a positive integer value: 20 Enter a positive integer value: 30 Enter a positive integer value: -1 The average of the 3 numbers you entered is 20. NOTE: The average could end up being a float HINT: Be sure to use a variable to keep track of how many numbers were entered

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions