{"id":6965,"date":"2021-10-11T16:52:51","date_gmt":"2021-10-11T16:52:51","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/validating-user-input-and-debugging\/"},"modified":"2021-10-11T16:52:51","modified_gmt":"2021-10-11T16:52:51","slug":"validating-user-input-and-debugging","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/validating-user-input-and-debugging\/","title":{"rendered":"Validating user input and debugging"},"content":{"rendered":"<div>\n<p>\u00a0<\/p>\n<h2>Overview<\/h2>\n<p>Many Java programs that you create will receive and process user input. In order to ensure that user input is accurate, you will need to use input validation and exception handling. For example, if you ask for a zip code, you want to ensure the user inputs a five-digit number. In this activity, you are given \u201cbuggy\u201d code for a paint program that calculates the number of cans of paint required to paint a wall, given the wall\u2019s height and width. You will need to debug the code and improve it by adding code to validate user input and handle exceptions.<\/p>\n<h2>Prompt<\/h2>\n<p>For this assignment, you will complete the paint program by debugging the original code and adding code that validates user input and handles exceptions. Use the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/course_documents\/Uploading%20Files%20to%20Eclipse%20Tutorial.pdf?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\">Uploading Files to Eclipse<\/a> and the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/course_documents\/Downloading%20Files%20from%20Eclipse%20Tutorial.pdf?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\">Downloading Files From Eclipse<\/a>\u00a0tutorials to help you with this project.<\/p>\n<ul>\n<li><strong>Debugging<\/strong>\n<ul>\n<li>Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open your IDE. Upload the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/course_documents\/Paint1.zip?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\">Paint1.zip<\/a> folder and review the code for the Paint1.java file.<\/li>\n<li>Find and fix the <strong>three<\/strong> errors in the given code.<\/li>\n<li>Use the input values below to test your program. If you found and fixed all errors, your output should <strong>exactly<\/strong> match what is below.<br \/><strong>TIP:<\/strong> When you run your program in Eclipse, it will prompt you to enter input in the Console window. If you cannot find this window, go to <strong>Window<\/strong>, then <strong>Show View<\/strong>, then <strong>Console<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"Input value table with the numerals 30 and 25\" height=\"125\" src=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/PastedImage_hgg7htmfhhn15bogqcv5xekee1negxqt00151476131.png?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\" width=\"500\"\/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"Output value table with the wall area as 750.0 square feet and the paint needed as 2.142857142857143 gallons\" height=\"123\" src=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/PastedImage_ybyd88qyk3okvpib5colytubnaluhllu00151476131.png?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\" width=\"500\"\/><\/p>\n<ul>\n<li><strong>Input Validation and Exception Handling<\/strong>\n<ul>\n<li>Review the code, looking for the two code blocks where user input is required.<\/li>\n<li>Implement a do-while loop in both blocks of code to ensure that input is valid and any exceptions are handled.<br \/><strong>TIP:<\/strong> Consider using a try-catch block for exception handling, but it is not required.<\/li>\n<li>Use the two sample invalid inputs below to test your program. Your program should respond to each by prompting the user to enter valid input. This should continue to loop until valid input is received.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"A table with two columns titled Input 1 and Input 2. The items under Input 1 are the spelled-out number thirty and the numeral 25. The items under Input 2 are the numerals 30 and 0.\" height=\"156\" src=\"https:\/\/learn.snhu.edu\/content\/enforced\/261238-IT-145-T1597-OL-TRAD-UG.19EW1\/PastedImage_ri7i3ykzjq7b5ezw2wwpoymx34jv4hab00151476131.png?_&amp;d2lSessionVal=tnp7mZ8eaPGehUBHOpVBL4GFf&amp;ou=261238\" width=\"300\"\/><\/p>\n<p><strong>THINK:<\/strong> Why is 0 invalid input for this problem? What is the user being asked to input?<\/p>\n<h2>Guidelines for Submission<\/h2>\n<p>Attach your completed Paint1.java file to the assignment submission page.<\/p>\n<h2>Module Six Assignment Rubric<\/h2>\n<p><strong>CriteriaProficient (100%)Needs Improvement (75%)Not Evident (0%)ValueDebugging<\/strong>Debugs a class so that no errors remain and calculations work correctlyMeets some \u201cProficient\u201d criteria, but with errors or exclusions such as one or two remaining bugsDoes not attempt criterion30<strong>Input Validation and Exception Handling<\/strong>Adds loops to validate all user input and handle exceptions so that code passes all test casesMeets most \u201cProficient\u201d criteria, but with errors; areas for improvement may include ability to handle all test casesDoes not attempt criterion70Total:100%\u00a0<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Overview Many Java programs that you create will receive and process user input. In order to ensure that user input is accurate, you will need to use input validation and exception handling. For example, if you ask for a zip code, you want to ensure the user inputs a five-digit number. In this activity, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-6965","post","type-post","status-publish","format-standard","hentry","category-homework-help"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/6965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=6965"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/6965\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=6965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=6965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=6965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}