Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add comments ty for your help Input and Nested If Statements and Functions and input validation. This assignment is more exercise with conditional statements

image text in transcribedimage text in transcribed\\ Add comments

ty for your help

Input and Nested If 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 a character from user input. - Name that function, getFirstnameChar_step10. - To show your work increments, implement each step as a separate function, called getFirstnameChar_step20, getFirstnameChar_step30, getFirstnameChar_step40 and getFirstnameChar_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 main0. stepl. Write the code that prompts the user to enter a character between ' e ' and ' o ' (including ' e ' and ' 0 '), reads the character using Scanner, and then prints the character that user entered in a statement that begins with "You entered a x ". (where x is the character you entered) step2. Add more code or modify your code so that if the user enters a character that is less than ' e ' or greater than ' o ", it prints out "The character you entered is not between ' e ' and ' o '." Otherwise, and only if the character is between ' e ' and ' o ', it prints the statement as before. step3. Add more code or modify your code so that if the user enters the characters ' e ', ' 1 ' or ' o ' "You entered an ...." instead of "You entered a ...". Note if user entered " i,, you print "You entered an i", But if user entered k, you print "You entered a k " step4. Add more code or modify your code so that if the user enters something that is not a character, i.e. includes numbers, your program does not print any of the above lines, but instead prints out "Hellooo! Your input could not be read as a character. Please Get a Programming Life!". Again, note that it doesn't make sense to test something to see if it is between ' e ' and ' o ' if it isn't even a character. So sequence your tests in a logical order of ruling out the various cases. Step5. This is the final step Add more code or modify your code so that if the user enters something invalid or a character not between ' e ' and ' o ' print invalid input and keep asking the user to input a character until a valid character between ' e ' and ' o ' is entered and then prints out the correct response. Each step should be developed on the previous step. Include comments in your code to explain what each of the 'if' statements is testing. Create a Project and Class called Refactoring. In the main finally comment out the calls to stepl, step2, step3 and step4 as you have already tested these. Do not comment out using //. But comment out each function using /../. So the only live code is the call to step5. But all the five methods should be provided in the file. Zip the whole project in a single zip file and submit the zip file

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions