Input and Nested If Statements and Functions Assignment | Homework Help Websites

Input and Nested If Statements and Functions

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

This assignment is more exercise with conditional statements and code to make your program more robust. It builds on what you learned in the previous assignment in that you must now use else conditions and conditional blocks. This assignment should help you remember how to use if, else, blocks, and nested if statements in case you need a refresher. professional writing services near me

The exercise is designed in a special way to show you how you should write large programs by adding a little bit at a time. Please do these steps one at a time. The practice you will follow is called “refactoring.”

Start by creating a function to get in integer from user input. Name that function, getUserValue_step1(). To show your work increments, implement each step as a separate function, called getUserValue_step2(), getUserValue_step3(), getUserValue_setp4() and getUserValue_setp5(). Each time, copy the code from the previous step, and then add the new modifications to the new function. Be aware that you will not always be adding to the end of the new function, and may even have to rearrange the order of the previous pieces, in order to satisfy the new expectations presented in one or more of the steps.

To test your code, call the function for whichever step you are working on from main().

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

step1. Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using Scanner, and then prints the value that they entered in a statement that begins with “You entered a “.

step2. Add more code or modify your code so that if the user enters a value that is less than 1 or greater than 20, it prints out “The value you entered is not between 1 and 20.” Otherwise, and only if the value is between 1 and 20, it prints the statement as before.

step3. Add more code or modify your code so that if the user enters the values 8, 11, or 18, the statement that is printed is “You entered an” instead of “You entered a”. Note in putting these things in a particular order, that testing for 8, 11, and 18 makes more sense if you already know that the number is between 1 and 20.

step4. Add more code or modify your code so that if the user enters something that is not a number, i.e. includes letters, your program does not print any of the above lines, but instead prints out “Idiot! Your input could not be read as a number. Get a life!”. Again, note that it doesn’t make sense to test something to see if it is between 1 and 20 if it isn’t even a number. So sequence your tests in a logical order of ruling out the various cases.

Step5. Add more code or modify your code so that if the user enters something invalid or an integer not between 1 and 20 print invalid input and keep asking the user to input a number until a valid number between 1 and 20 is entered and then prints out the correct response.

Include comments in your code to explain what each of the ‘if’ statements is testing. 

Zip the java file in a single zip file and submit the zip file.

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works

Here is how simple it is to make use of our essay writing services

step 1

Submit a "write my essay for me" request

Fill out a quick order form and provide detailed requirements as to the paper, its format, etc. You can even attach screenshots or add additional instructions later. If something has to be clarified or added, the writer will contact you directly.
Pro service tips
How to get the most out of your experience with Homework Writing Services
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
IT
Well researched
Customer 463377, May 15th, 2023
Statistics
Thank you for your neat and precise work, very professional
Customer 462485, May 22nd, 2022
Education
Great job
Customer 463647, January 10th, 2023
SEO
Great work.Recommendable
Customer 463647, May 14th, 2023
Business and administrative studies
Outstanding work!!
Customer 460073, August 4th, 2022
Other
Good.
Customer 462635, June 14th, 2022
Military
good job
Customer 456821, February 28th, 2022
Human Resources Management (HRM)
Thank you .
Customer 464767, February 5th, 2024
Social Work and Human Services
Thanks
Customer 463783, October 21st, 2023
Psychology
Thank you.
Customer 463363, September 23rd, 2022
Education
Nice try.
Customer 452441, April 19th, 2022
Other
I received a MA which is mastered on the rewrite.
Customer 463143, July 10th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat