Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will determine the minimum number and sum of all the numbers entered by the user that are greater than 2 0

Write a program that will determine the minimum number and sum of all the numbers entered by the user that are greater than 20. Create a priming read to prompt the user to enter a number or 0 to quit. Create a sentinel value while loop that continuously prompts the user to enter a number or 0 to quit. In the loop you should determine if the number entered is greater than 20. If it is you should determine if it is the minimum value, and sum the number. When the user enters 0 the program should stop and print out the minimum number and the sum. Your output should match the sample runs below, including labels. User input is shown in bold:
Sample Run 1:
Enter a number or 0 to quit: 10
Enter a number or 0 to quit: 25
Enter a number or 0 to quit: 5
Enter a number or 0 to quit: 34
Enter a number or 0 to quit: 65
Enter a number or 0 to quit: 21
Enter a number or 0 to quit: 0
The minimum number greater than 20 is: 21
The sum of the numbers greater than 20 is: 145
Sample Run 2:
Enter a number or 0 to quit: 5
Enter a number or 0 to quit: 22
Enter a number or 0 to quit: 98
Enter a number or 0 to quit: 13
Enter a number or 0 to quit: 0
The minimum number greater than 20 is: 22
The sum of the numbers greater than 20 is: 120
Step 2: Modify the program to execute the above code a random number of times(sets). The program would generate a random number between 1 and 5, then prompt the user for numbers until they enter zero. It should then display the minimum and sum of those numbers greater than 20. It should continue doing this for the number of times determined by the random number. User input is shown in bold.
Sample Run 1:
Number of sets to calculate: 3
Enter a number or 0 to quit: 5
Enter a number of 0 to quit: 22
Enter a number of 0 to quit: 98
Enter a number of 0 to quit: 13
Enter a number of 0 to quit: 0
The minimum number greater than 20 is: 22
The sum of the numbers greater than 20 is: 120
Enter a number or 0 to quit: 2
Enter a number of 0 to quit: 3
Enter a number of 0 to quit: 4
Enter a number of 0 to quit: 5
Enter a number of 0 to quit: 6
Enter a number of 0 to quit: 0
The minimum number greater than 20 is: 0
The sum of the numbers greater than 20 is: 0
Enter a number or 0 to quit: 13
Enter a number of 0 to quit: 14
Enter a number of 0 to quit: 0
The minimum number greater than 20 is: 0
The sum of the numbers greater than 20 is: 0

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

Students also viewed these Databases questions