Question: Java problem! somebody helps please? creating an acceptable integer value class: Consider a Java ValidInt class that you could use to get an acceptable integer

Java problem! somebody helps please?

creating an acceptable integer value class:

Consider a Java ValidInt class that you could use to get an acceptable integer value from the user. An object of this class will have these attributes:

the minimum accepted int value (inclusive)

the maximum accepted int value (inclusive)

a prompt String used to ask for the integer

and the following method:

getValue() displays/prints 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 in a validation do-while loop until an acceptable value is entered. The method then returns the int value read.

Write precondition and postcondition comments for getValue(). A preconditions says what must be true before the method runs; a postcondition says what will be true after it runs.

Implement a ValidInt class in Java. You will need to create an initialize() method that sets all three instance variables, create and initialize some ValidInt objects in a main method, and write Java statements to test getValue() in main.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!