Open userinput.java in drjava. the program will ask the user to enter

 Open UserInput.java in DrJava. The program will ask the user to enter a range of values and then display them. 

Note that it includes commented out calls to the methods that you will define. 

Once you’ve implemented the relevant method you can uncomment those lines to test your implementation. 

Implement askForInt The new method askForInt is intended to prompt the user to enter an integer within a given range, read their response, and to continue prompting them and reading their response until it is within that range.

 Implement askForInt based on the following pseudocode description (where variable values appearing in output are highlighted): 

Method: int askForInt(Scanner in, String prompt, int min, int max) Returns: int, 

the valid value entered by the user Parameters: Scanner in, the Scanner to read user input String prompt, 

the message to prompt the user with int min, the lower bound of the allowed range int max, the upper bound of the allowed range Variables: 

int value, value entered by user 

Steps: 1 Display “prompt (min-max): ” on one line 

2 Assign value result of in.nextInt() 

3 While value < min or value > max: 

3-1 | Display “Invalid value” 

3-2 | Display “prompt (min-max): ” on one line 

3-3 | Assign value result of in.nextInt() 

4 Return value Note: Remember to use appropriate Java syntax for the while loop and logical or Add a suitable header comment to explain what this method does. 

Keep the description general; 

do not tailor it to suit the way it is used by the testing code in main. In the main() method remove the comment that reads in the value for the guess variable. 

Compile and run the program and test it by entering -50, then 11, before trying a valid value. 

Implement askForDouble Using the same pattern as above, design and implement askForDouble, and test using the percent value in main(). 

Hint: The changes are very slight, so copy, paste and modify. 

Don’t forget to modify the header comment as well. 

In the main() method remove the comment that reads in the value for the percent variable. 

Compile and run the program and test it with a variety of incorrect inputs before trying a valid value. 

Implement askForYesNo The Scanner’s nextBoolean() method does exactly what it claims—reads the next piece of text that is ‘true’ or ‘false’ and returns a boolean—and nothing more. 

So it’s fine for providing basic interaction, especially with other programmers, but it’s not a great way for a normal user to enter a truth value. 

Design and implement askForYesNo. 

You can use the previous two methods as a guide but make the following key changes: Remove the min and max parameters. Knowledge of valid values will be built-in to the method. 

Display the prompt followed by suitable explanatory text such as ‘(yes/no)’. Do not use nextBoolean(), since it only works with the inputs ‘true’ and ‘false’. Instead use the Scanner’s next() method to read in the next String the user enters. If the user enters “y”, “yes” or “true” (in any case) then the method should return true. If the user enters “n”, “no” or “false” (in any case) then the method should return false. If they enter any other value then display an error and prompt them again, as done in askForInt and askForDouble. 

Tips: Use the String method toLowerCase() to convert the user’s input to a value suitable for comparing against the valid alternatives. (As with all String methods, it returns a copy of the modified String, it does not actually change the String on which it is called.) 

You can use either an if or switch construct for checking (and converting) the user’s input. 

Consider declaring two boolean variables in your method, one the value to be returned and another indicating if the current input is actually valid. 

Consider using a do-while loop (and the ‘is valid’ variable suggested above) as this will reduce the amount of code you need to write. As with the previous two methods, add a method header comment containing a general description of the method’s behaviour (not a description of the example usage shown in main). 

In the main() method remove the comment that reads in the value for the again variable. Compile and run the program and test it with a variety of incorrect inputs before trying a valid value. Remember that upper case or mixed case entries are valid if they match any of the six possible input values. 

Calculate the price of your order

Choose an academic level, add pages, and the paper type you want.
To reduce the cost of our essay writing services, select the lengthier deadline.
We can't believe we just said that to you.

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Why is Purdue Papers the Most Helpful Essay Writing Service for You?

  1. Custom-written and plagiarism-free papers: Our authors create their work from scratch. Before presenting them to clients, we routinely verify them for signs of plagiarism. Our quality assurance group also double-checks and fixes any grammatical errors, assuring that all of our authors adhere to the same standards of writing.
  2. The significance of timely delivery cannot be overstated, and we consistently strive to meet or exceed our clients' deadlines. Regardless of the short time frame, you can count on our writers to get the job done. We always have a team of writers ready to go, even if the deadline is only six hours away.
  3. Customer Satisfaction: Our customer service representatives are the best in the business and have a wealth of knowledge in dealing with clients. All our customer service representatives are trained to listen and reply promptly until you are satisfied with their service. To ensure you're happy, our expert writers will strictly follow the criteria to generate a special report. Our customer service may be contacted by chat, email, or phone. In addition, we provide round-the-clock assistance to all of our clients.
  4. Confidentiality: Our systems are safe, and your information is always protected. We're constantly looking for new facts when it comes to finishing your work. We use a safe and secure payment channel. Since our ordering process is completely anonymous, you don't have to provide any credit card information to place a purchase with us.
  5. Highly Trained Authors: Our writers have received extensive training and are committed to delivering only the best papers. They are fluent in APA, MLA, HARVARD, IEEE, CHICAGO, and AMA referencing styles. To meet your expectations, our skilled writers always pay close attention to your instructions.
  6. Lowered prices: We have set prices that are already discounted. Our prices are the best and affordable for all our esteemed customers.

Let Professionals Take Care of your Academic Paper