E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud is byu chat page TestOut LabSim X Package Name: week5 . Class Name: InputValidationInteger When submitting this lab, submit a java file called "InputValidationInteger", and create the following structure in Eclipse: + } while (!valid); Step 7: Ponder and discuss with your partner the following: Course Hero Write a program that asks the user to enter a whole number. Use input validation to ensure the user entered a valid whole number. Perform simple math on the number to ensure your input validation routine worked as expected. Display the results. Step 1: Create a class, InputValidationInteger with a main() method. Step 2: Declare a Scanner object, in. Step 3: Declare a String variable, input, and initialize it to "". Step 4: Declare three integer variables num1, num2, and num3 and initialize them to 0. Step 5: Declare a boolean control variable, valid, and set it to false. Step 6: Create a do-while loop using the valid control variable. do { a I O 6:47 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources do{ Course Hero iCloud is byu chat page The program should now look something like this: //Declare variables } catch (Exception e) { Step 8: In the body of the do-while loop, prompt the user to enter a number. Step 9: Use in.nextLine() to get the input from the user. Step 10: Create a try/catch statement inside your while loop. Use the standard Exception to catch all exceptions in the catch statement. System.out.print("Please enter a number: "); input = in.nextLine(); try{ }//end of try/catch }while (!valid}; X TestOut LabSim + Course Hero a I O 6:48 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud s byu chat page Example Run X Step 11: In the try block, convert the user's input into an integer and store it in num1 using Integer.parseInt(). Please enter a number: Pizza Invalid Response! Please enter a whole number. Please enter a number: Uno TestOut LabSim Step 12: If the parseInt() statement ran without issue, then you can set valid = true so that the program will exit the do-while loop once a valid integer has been entered. Add the following statement to the try block: valid = true; Step 13: If the user entered something other than a valid integer, the code in the catch block will run without crashing the program. Display a helpful message prompting the user to correct the error inside the catch block: + System.out.println("Error: Please enter a whole number. "); Step 14: Outside of the do-while loop, perform the following mathematical calculations: Set num2 to equal num1 + 1000. Set num3 to equal num1 * 2. Step 15: Print out num1, num2, and num3 as shown in the example run. Course Hero a I O 6:48 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Example Run Course Hero iCloud is byu chat page Please enter a number: Pizza Invalid Response! Please enter a whole number. Please enter a number: Uno Invalid Response! Please enter a whole number. Please enter a number: 42 num1 = 42. num2 = 1042. num3 = 84. Step 13: If the user entered something other than a valid integer, the code in the catch block will run without crashing the program. Display a helpful message prompting the user to correct the error inside the catch block: System.out.println("Error: Please enter a whole number. "); Step 14: Outside of the do-while loop, perform the following mathematical calculations: Set num2 to equal num1 + 1000. Set num3 to equal num1 * 2. Step 15: Print out num1, num2, and num3 as shown in the example run. X TestOut LabSim + Course Hero a I O 6:48 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud is byu chat page TestOut LabSim X Package Name: week5 . Class Name: InputValidationInteger When submitting this lab, submit a java file called "InputValidationInteger", and create the following structure in Eclipse: + } while (!valid); Step 7: Ponder and discuss with your partner the following: Course Hero Write a program that asks the user to enter a whole number. Use input validation to ensure the user entered a valid whole number. Perform simple math on the number to ensure your input validation routine worked as expected. Display the results. Step 1: Create a class, InputValidationInteger with a main() method. Step 2: Declare a Scanner object, in. Step 3: Declare a String variable, input, and initialize it to "". Step 4: Declare three integer variables num1, num2, and num3 and initialize them to 0. Step 5: Declare a boolean control variable, valid, and set it to false. Step 6: Create a do-while loop using the valid control variable. do { a I O 6:47 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources do{ Course Hero iCloud is byu chat page The program should now look something like this: //Declare variables } catch (Exception e) { Step 8: In the body of the do-while loop, prompt the user to enter a number. Step 9: Use in.nextLine() to get the input from the user. Step 10: Create a try/catch statement inside your while loop. Use the standard Exception to catch all exceptions in the catch statement. System.out.print("Please enter a number: "); input = in.nextLine(); try{ }//end of try/catch }while (!valid}; X TestOut LabSim + Course Hero a I O 6:48 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud s byu chat page Example Run X Step 11: In the try block, convert the user's input into an integer and store it in num1 using Integer.parseInt(). Please enter a number: Pizza Invalid Response! Please enter a whole number. Please enter a number: Uno TestOut LabSim Step 12: If the parseInt() statement ran without issue, then you can set valid = true so that the program will exit the do-while loop once a valid integer has been entered. Add the following statement to the try block: valid = true; Step 13: If the user entered something other than a valid integer, the code in the catch block will run without crashing the program. Display a helpful message prompting the user to correct the error inside the catch block: + System.out.println("Error: Please enter a whole number. "); Step 14: Outside of the do-while loop, perform the following mathematical calculations: Set num2 to equal num1 + 1000. Set num3 to equal num1 * 2. Step 15: Print out num1, num2, and num3 as shown in the example run. Course Hero a I O 6:48 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.4 Lab-Input Validation (1 hr. 30 X ensign.instructure.com/courses/14050/assignments/798604?module_item_id=1612087 Announcements Syllabus Modules Grades People X Tutoring Resources Example Run Course Hero iCloud is byu chat page Please enter a number: Pizza Invalid Response! Please enter a whole number. Please enter a number: Uno Invalid Response! Please enter a whole number. Please enter a number: 42 num1 = 42. num2 = 1042. num3 = 84. Step 13: If the user entered something other than a valid integer, the code in the catch block will run without crashing the program. Display a helpful message prompting the user to correct the error inside the catch block: System.out.println("Error: Please enter a whole number. "); Step 14: Outside of the do-while loop, perform the following mathematical calculations: Set num2 to equal num1 + 1000. Set num3 to equal num1 * 2. Step 15: Print out num1, num2, and num3 as shown in the example run. X TestOut LabSim + Course Hero a I O 6:48 PM 10/11/2022 X :
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Using real employed samples, multiple field studies indicate that fat women experience more negative outcomes than fat men. In one study conducted by Steven Gortmaker and colleagues and using over...
-
Is there a distinction between thermal energy and internal energy? Which term do physicists prefer?
-
Solve for x. Here, we see that we can solve an equation in which the unknown is an element of a determinant. 25 1 X 3
-
Refer to the information in Problem 21-1B. Tohono Companys actual income statement for 2017 follows. Required 1. Prepare a flexible budget performance report for 2017. Analysis Component 2. Analyze...
-
A tabular analysis of the transactions made during August 2010 by Witten Company during its first month of operations is shown below. Each increase and decrease in stockholders equity is explained....
-
3. (a) Find the binary representation of /3. (b) By noting that -9.6= (-1) 23 1.2. x Use the result in (a), represent -9.6 in IEEE single precision format through rounding. (c) Represent the result...
-
Acme Pharmaceutical Company (APA) has discovered, after years of research, that the bark of the samosa tree, found only in the highlands of Papua New Guinea, has remarkable curative effects on some...
-
Mariam would like to see the breakdown of Employee's Monthly Income, by Department and Job Role ( Vertically ) and Education Field ( Horizontally ). Mariam would also like to be able to Filter the...
-
Growth Company is a global power and automation technologies firm that is listed on the Stock Exchange. It is all equity funded at present (no debt) and has recently decided to proceed with a...
-
The figure shown below represents the master curves of two mixes (A and B). The phase angle of mix A is 35, and the phase angle of Mix B is 29. a) (3 Pts.) The mix with higher resistance to rutting...
-
The following two liquid-phase reactions occur in parallel within a well-mixed, isothermal CSTR: A+B -->D (1) A+B --> U (2) The rate laws for these two reactions are rp = kC and ru KCACB. The rate...
-
Through what intricate processes do social behaviors and inequalities evolve and manifest in individuals' daily lives, considering the interplay of various socio-cultural, economic, and institutional...
-
Write an HTML code for the following webpage (Form). Please complete the form below. Mandatory fields marked Delivery Details Name Address Town/City County Postcode* Is this address also your invoice...
-
In your audit of Garza Company, you find that a physical inventory on December 31, 2012, showed merchandise with a cost of $441,000 was on hand at that date. You also discover the following items...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Deborah purchases a new $30,000 car in 2012 to use exclusively in her business. If Deborah does not elect to expense or take bonus depreciation in 2012 and holds the car until it is fully...
-
Mike sells his home to Jane on April 2, 2012. Jane pays the property taxes covering the full calendar year in October, which amount to $2,500. How much may Mike and Jane each deduct for property...
-
Draw a cash flow diagram of any investment that exhibits both of the following properties: 1. The investment has a 4-year life. 2. The investment has a 10 percent/year internal rate of return.
-
What is the internal rate of return of the following cash flow diagram? a. 20 percent b. 18.2 percent c. 17.5 percent d. 15 percent $30 $31 0 1 2 3 $30 $15
-
Quilts R Us (QRU) is considering investing in a new patterning attachment with the cash flow profile shown in the table below. QRU's MARR is 13.5 percent/year. a. What is the internal rate of return...
Study smarter with the SolutionInn App