Question: Question 1 [ 3 mark ] Find the Smallest Number Write a simple program that helps a user find the smallest positive number among a
Question mark Find the Smallest Number
Write a simple program that helps a user find the smallest positive number among
a limited series of positive integers entered by the user. The program should
perform the following tasks:
Prompt the user to enter a series of positive integers: The program should
repeatedly prompt the user to enter up to positive integers, separated by
blanks. The user can enter no more than positive integers, and to indicate
the end of input, the user should enter The program will omit the integers
after
Wrong Condition : If the user enters a nonpositive integer
excluding display an error message and terminate the program.
The program should not consider negative integers.
Example: Note: is a nonpositive integer before ending
Example: Note: is a nonpositive integer before ending
Example: Note: is a nonpositive integer before ending
Example: Note: is a nonpositive integer before ending
Example: Note: is a nonpositive integer before ending
For these examples, the program display:
Wrong Condition : If the user enters a noninteger value eg a
letter or a symbol display an error message and terminate the
program. The program should not consider this input.
Example: B C Note: B is a noninteger value before ending
Example: B Note: B is a noninteger value before ending
Example: $ Note: $ is a noninteger value before ending
Example: A B C Note: A is a noninteger value before ending
Example: & Note: & is a noninteger value before ending
For these examples, the program display:
Error: Nonpositive integer.
Thank you for using the program!
Error: Not ended with
Thank you for using the program!
Wrong Condition : If the user only enters or the first integer is
display an error message and terminate the program.
Example: Note: only enters
Example: Note: the first integer is
For these two examples, the program display:
Wrong Condition : If the number of positive numbers is more than
before the ending display an error message and terminate the
program.
Example: Note: the number of positive numbers is
more than before the ending
Example: Note: the number of positive numbers is
more than before the ending
For these two examples, the program display:
The program will only report the first error it meets.
Example: A Note: the first error is nonpositive integer.
For this example, the program display:
Error: Nonpositive integer.
Thank you for using the program!
Error: Only
Thank you for using the program!
Error: Noninteger value.
Thank you for using the program!
Find the smallest positive number: After the user finishes entering feasible
numbers and enters to stop, the program should determine the smallest
positive number from the entered values.
Display the smallest positive number: The program should display the
smallest positive number to the user.
Ask the user if they want to repeat the process: After displaying the
smallest positive number, the program should ask the user if they want to
find the smallest positive number again with a new series of positive
integers. If the user responds with Y repeat the process. If the user
responds with N end the program. Other responses, such "abc" and "aaa",
will also end the program Please refer to the Example below
The examples have considered most cases for test. Please carefully read the
examples, which will help you to fully understand the above question.
Ensure that the program output follows the format of the following examples.
Otherwise, you will not pass the test.
For example, Enter up to positive integers, separated by blanks. To stop,
enter and press Enter: You should not misspell any words. A good
strategy is to directly copy the sentence and use it in your program.
Example
Enter up to positive integers, separated by blanks. To stop, enter and press Enter:
The smallest positive number is:
Do you want to find the smallest positive number again? YN:
Y
Enter up to positive integers, separated by blanks. To stop, enter and press Enter:
The smallest positive number is:
Do you want to find the smallest positive number again? YN:
N
Thank you for using the program!
Example
Example
Example
Example
Example
Enter up to positive integers, separated by blanks. To stop, enter and press Enter:
Error: Only
Thank you for using the program!
Enter up to positive integers, separated by blanks. To stop, enter and press Enter:
The smallest positive number is:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
