Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CMPS 147 - Homework #2 For this assignment you are to write a program that finds the minimum and maximum of a set of numbers

image text in transcribed
image text in transcribed
image text in transcribed
CMPS 147 - Homework #2 For this assignment you are to write a program that finds the minimum and maximum of a set of numbers entered by the user. Your program should enter a loop in which it repeatedly asks the user to enter a number. The program should exit the loop if the user enters a "-1". While in this loop, the program must keep track of the smallest and largest numbers entered by the user. After the user enters a "-1" the program should output the minimum and maximum. Users may not enter any numbers less than 0 (other than-1 to stop) or greater than 9999. Hint Keep track of the "current" minimum and maximum in separate variables. Each time the user enters a number, you may need to update these variables. After printing the minimum and maximum, your program should ask the user if they wish to continue by entering yes (V) or no (w). If they continue your program should start over, if the user enters the program should quit. In total, you should have two loop structures. (1) an outer loop controlling how many times the user "repeats" the entire program (Do you wish to continue?) , (2) an inner loop that allows the user to repeatedly enter in numbers for which you will find the minimum and maximum. Here is a sample of the input and output for your program. The user has entered text in red (bold) and the program has printed out text in black > Please enter as many numbers as you like. Enter -1 to stop. > Please enter a numbert 16 > Please enter a number: 46 > Plose enter number: 19 > Please enter a number: 6 > Planonter a number: 98 > Please enter a number: 56 > Please enter a numbert-1 > > Maximum 95 > Minimum 6 > Do you wah to continue? (yity WWW Maximum: 98 > Minimum: 6 > > Do you wish to continue? (y): y > > Please enter as many numbers as you like. Enter -1 to stop. > Please enter a number: 9 > Please enter a number: 128 > Please enter a number: 18 > Please enter a number: -1 > > Maximum: 128 > Minimum: 9 > > Do you wish to continue? (y): n > Goodbye. Your program should not accept any numbers less than-1 or greater than 9999 and should war the user when they enter numbers out of this range. Your program should not exit - just warn the user! they > Please enter as many numbers as you like. Ent -1 to stop. > Please enter a number: 16 > Please enter a number: -6 > I accept positive numbers less than 9999 (or -1 to stop) > Please enter a number: 19 > Please enter a number: 6 > Please enter number: 54023 > I accept positive numbers less than 9999 (or -1 to stop) > Please enter a number: 12 > I accept positive numbers less than 9999 (or -1 to stop) > Pleasantor & numer 98 > Pleasanter number: 56 > Pienso enter number 1 > Stammt 98 in 6 > Do you wah to continue? ): 9 > Minimum: > > Do you wish to continue? (y): n > Goodbye. Your program should not accept any numbers less than-1 or greater than 9999 and should war the user when they enter numbers out of this range. Your program should not exit - just warn the user! > > Please enter as many numbers as you like. Enter -1 to stop. > Please enter a number: 16 > Please enter a number: -6 > I accept positive numbers less than 9999 ( or -1 to atop) > Please enter a number: 19 > Please enter a number: 6 > Please enter a number: 54023 > I accept positive numbers less than 9999 ( or -1 to stop) > Please enter a number: -12 > I accept positive numbers less than 9999 (or -1 to stop) > Please enter a number: 98 > Please enter a number: 56 > Please enter a number: 1 > Maximum: 98 > Minimum > Do you wish to continue? [y) in > Goodbye. Hint: Attack this problem piece by piece. First get it to read in numbers until the user enters-I. Next work on getting it to calculate the maximum and minimums. Only after you get those parts correct should you begin to work on getting the program to handle out of range numbers (Warnings) and asking the user to contine (start all overore

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions