Consider a Java class that you could use to get an acceptable integer value from the user. An object of this class will have the attributes
• Minimum accepted value
• Maximum accepted value
• Prompt string
and the following method:
• getValue displays the prompt and reads a value using the class Scanner. If
the value read is not within the allowed range, the method should display an error message and ask the user for a new value, repeating these actions until an acceptable value is entered. The method then returns the value read.
a. Write preconditions and postconditions for the method getValue.
b. Implement the class in Java.
c. Write some Java statements that test the class.
Preconditions: minimum value is less than or equal to maximum value
Postconditions: the value returned will be greater than or equal to the minimum and less than or equal to the maximum.
See the code in GetInput.java.
You might also like to view...
The value that a function produces appears in the function's ____.
A. parameter list B. return statement C. declaration statement D. storage class
A ____ is a set of instructions that you specify to automate certain database tasks.
A. data access page B. form C. report D. macro
Which of the following is not true regarding the system development life cycle?
A) The system development life cycle is a triangular process. B) The system development life cycle is a methodology that follows a project from the initial idea to the development, implementation, and review of the idea. C) You might have a particular idea, but someone else might implement it or review it. D) Each step in the process requires different skills.
How is the Guest account a security risk?
What will be an ideal response?