Question
Programming Fundamentals Divide by Zero Input Validation this focuses on input validation as it relates to performing division.You should be familiar with using either the
Programming Fundamentals
Divide by Zero Input Validation
this focuses on input validation as it relates to performing division.You should be familiar with using either the while loop or do-while loop to check inputs provided by the user.
Create a project called DBZValidation_FirstName_LastName . Remember to include comments summarizing the program.
1.Import the JOptionPane class, and declare a String that will hold the users input from each input dialog box.
2.Declare three double variables to hold the numerator, denominator, and quotient for the division operation that will be performed in this program.
3.Display the first input dialog box to the user asking for the numerator and store the users input into the String variable. Convert the users input to a double and store this into the appropriate double variable.
4.Display the second input dialog box to the user asking for the denominator and store the users input into the String variable. Use either a while loop or do-while loop to perform input validation by comparing the users input to the String literal 0. If the user entered 0, repeat the request for the denominator. If the user did not enter 0, convert the users input to a double and store this into the appropriate double variable.
5.Divide the numerator(the first input) by the denominator(the second input) and store the resulting quotient into the appropriate double variable. Display a message dialog box to the user indicating the quotient rounded to two decimal places.
6.Since the program uses dialog boxes, make sure to properly exit the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started