Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help with programing in eclipse Assignment : Question 1 (100 points) Input and Nested I Statements and Functions and input validation This assignment is more

image text in transcribed

image text in transcribed

help with programing in eclipse

Assignment : Question 1 (100 points) Input and Nested I Statements and Functions and input validation 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 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, getFirstnameValue stepl(). To show your work increments, implement each step as a separate function, called getFirstnameValue_step20. getFirstnameValue step30. getFirstname Value_step40) and getFirstname Value step50. Each time, copy the code from the previous step, and then add the new modifications to the new function. Use your FirstName in the function names 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(). 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 modily your code so that if the user enters a value that is less than I 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. Step 4. 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. Step 5. Add more code or modily 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. You may discuss assignments with other students, but you must do your work separately. PLEASE Do not submit a copy of the same work as another student

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

Students also viewed these Databases questions

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago