1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Serjik [45]
3 years ago
14

4.15 LAB: Password modifier

Computers and Technology
1 answer:
Black_prince [1.1K]3 years ago
3 0

I've included my code in the picture below. Best of luck.

You might be interested in
When working in the navigation pane, you ____ a folder to open it?
SpyIntel [72]
When working in the navigation pane, you click a folder to open it
3 0
3 years ago
Write a simple command-line calculator with an exception handler that deals with nonnumeric operands. Your program should displa
alexira [117]

Answer:

Here is the JAVA program:

import java.util.InputMismatchException;  // exception that is thrown when input does not match the expected type

import java.util.Scanner;  //used to take input from user

public class Main {

public static void main(String[] args) { //start of main function

   Scanner input = new Scanner(System.in);  // creates Scanner class object

   double num1=0.0;  // double type operand 1

   double num2=0.0;  // double type operand 2

   System.out.println("Please enter 2 operands");  //prompts user to enter two operands

   try {  //defines a chunk of code to be tested for non numeric operand error

      num1 = input.nextDouble();  //reads operand 1 value

      num2 = input.nextDouble(); //reads operand 2 value

         

   } catch (InputMismatchException  ex) {  //code chunk executed when exception occurs in program

     System.out.println("wrong operand type, re-input " + input.next() + " to finish the calculation.");  //displays wrong operand type if user enters non numeric operands

     System.exit(1);  }//exits the program    

   System.out.print("Enter an operator (+, -, *, /): ");  //prompts user to enter an operator

       char operator = input.next().charAt(0);  //reads the input operator

       double result;  // to store the result of the operation

       switch(operator)         {  //decided operation on basis of input operator

           case '+':  // if user enters + operator

               result = num1 + num2;  //adds two operands

               break;

            case '-':  // if user enters - operator

               result = num1 - num2;  //subtracts two operands

               break;  

           case '*':  // if user enters * operator

               result = num1 * num2;  //multiplies two operands

               break;  

           case '/':  // if user enters / operator

               result = num1 / num2;  //divided two operands

               break;  

           default:  //if user enters wrong operator

               System.out.printf("wrong operator!");  //displays wrong operator

               return;          }  

       System.out.printf("%.1f %c %.1f = %.1f", num1, operator, num2, result); }} //displays the result of the operation

Explanation:

The program is well explained in the comments mentioned with each line of program. The user is prompted to enter the values of two operands num1 and num2. The try block is used to test for non numeric operand error and throws InputMismatchException when any of the input operands (num1 or num2) is non numeric. InputMismatchException is thrown by Scanner class. This informs that the token retrieved (which is the num1 or num2 operand) does not match the expected type (which is type numeric). When this error occurs in the program, catch block is used to execute a code chunk, which is the print statement in this program. The print statement informs the user of the wrong operand type before exiting. It also asks the user to re-input the number to finish the calculation and the wrong input type is also mentioned in the output that is to be re-input.

If you want the program to take the input again from user after throwing this exception then you can alter the above program by using two try catch blocks separately for the two operands:

//for operand 1 i.e. num1

System.out.println("Please enter operand 1: ");

   try {

      num1 = input.nextDouble();        

   } catch (InputMismatchException  ex) {

     System.out.println("wrong operand type, re-input " + input.next() + " to finish the calculation.");

      num1 = input.nextDouble();  }  //reads input of operand 1 again from user

//for operand 2 i.e. num2

          System.out.println("Please enter operand 2: ");  

      try {

      num2 = input.nextDouble();  

   } catch (InputMismatchException  ex) {

     System.out.println("wrong operand type, re-input " + input.next() + " to finish the calculation.");

     num2 = input.nextDouble();  } //reads input of operand 1 again from user

The program and its output is attached.

8 0
4 years ago
While traditionally employers used computers to track ordering and inventory, computers are used now to
AlexFokin [52]

Answer:

The correct answer should be A. automate merchandise ordering and inventorying.

5 0
4 years ago
A device that does not work well in a system can sometimes be improved by updating its ___computer ____________.
Semenov [28]
I believe its "By updating its computer driver i know its not software im pretty sure its a driver because all the components in a comuter have a specific driver and they need to be mainitanced yearly. P.s Glad to help you.
5 0
3 years ago
he IT director asks you to verify that the organization's virtualization technology is implemented securely. What should you do
Kamila [148]

Answer:

Check that virtual machines have always had the upcoming services packs as well as patches set up.

Explanation:

  • Among the very most essential preventive measures, you could even begin taking would be to download the application security relies on upon and splotches. The whole principle applies to routine OS, implementations as well as virtualization software.
  • It would not be appropriate for software applications to have been multihomed even though it will not seem to significantly boost their protection.
  • Penetration testing is being managed to complete before the implementation of virtual servers. Subnetting isn't necessary for virtual servers, and while it may improve safety. It must be factored into the equation during most of the capacity building phase.
7 0
3 years ago
Other questions:
  • What is a digital certificate? Select one: a. It is a means of establishing the validity of an offer from a person, entity, web
    7·1 answer
  • Liam is a hacker who tries to access Wi-Fi signals while driving his car. What type of wireless network attack is this?
    9·1 answer
  • ASAP ε=ε=ᕕ(°□°)ᕗ<br> Sorry if you can't see it but please help me if you can!
    6·1 answer
  • Betty removed a web page from her website. Some users were browsing on her website. One of them clicked on a particular link and
    15·1 answer
  • Using truth table, prove that:<br><br> (A + B). C = (A . C)+ (B .C) ?
    7·1 answer
  • Create two Lists, one is ArrayList and the other one is LinkedList and fill it using 10 state names (e.g., Texas). Sort the list
    6·1 answer
  • Write a number guessing game. The game should have a default 1-100 picking system. Have the user guess the number the computer p
    12·1 answer
  • There are many advantages and some disadvantages to using social media. Explain at least one of the advantages to
    5·1 answer
  • Which type of project data would you review for an accurate picture of the project progress and labor costs
    8·1 answer
  • The science of networking is attributed to which government's involvement?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!