Question: Suppose that there is a void method named ValidatePassword that is passed a username and password, both as a String type, and throws an InvalidPasswordException

Suppose that there is a void method named ValidatePassword that is passed a username and password, both as a String type, and throws an InvalidPasswordException if the provided password is incorrect for the username passed, otherwise produces no result. Make the changes in the following code to prompt for a specific username and password, and display either Invalid Password Provided, or You are now logged in. (3 pts.)

public static void main(String args[])

{

int num1, num2;

boolean valid_input = false;

Scanner input = new Scanner(System.in);

while (!valid_input)

{

System.out.println(Enter numerator denominator );

num1 = input.nextInt();

num2 = input.nextInt();

try

{

result = quotient(num1, num2);

System.out.println(The result of + num1 + / + num2 + is + result);

valid_input = true;

}

catch ( ArithmeticException ex)

{

System.out.println(Second number entered must be non-zero);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!