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
kolbaska11 [484]
3 years ago
8

If the user enters any operator symbol other than , -, *, or /, then an UnknownOperatorException is thrown and the user is allow

ed to reenter that line of input. Define the class UnknownOperatorException as a subclass of the Exception class. Your program should also handle NumberFormatException if the user enters non-numeric data for the operand.
Computers and Technology
1 answer:
Anna007 [38]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It creates the UnknownOperatorException class and catches it if the user enters something other than the valid operators. If so it continues asking the user for a new input. Once a valid operator is entered, it exits the function and prints the operator.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       char symbol = askForOperand();

       System.out.println("Operand: " + symbol);

   }

   public static char askForOperand() {

       Scanner in = new Scanner(System.in);

       try {

           System.out.println("Enter operator symbol: ");

           char symbol = in.nextLine().charAt(0);

           if ((symbol != '-') && (symbol != '*') && (symbol != '/')) {

               System.out.println(symbol);

               throw new UnknownOperatorException();

           } else {

               return symbol;

           }

       } catch (NumberFormatException | UnknownOperatorException e) {

           System.out.println("Not a valid operand");

           char symbol = askForOperand();

           return symbol;

       }

   }

}

class UnknownOperatorException extends Exception {

   public UnknownOperatorException() {

       System.out.println("Unknown Operator");

   }

}

You might be interested in
A relational database is different from a simple database because it has more than one _____.
arsen [322]

Answer:

A relational database is different from a simple database because it has more than one _____.

The answer to this should be more than one tables

Explanation:

The main difference between simple database and relational database is there data storing technique like simple database store data in the form of files and in relational database for data arrangement tables are used where the header is the name of of attributes/columns and rows contain the values of those attributes. Other difference is that simple database might be single user but relational database is multi user. There are many other difference are also available which make Relational Database the advance version.

I hope it will help you!

5 0
3 years ago
Meera has created a small program in Python. She wants to store elements of the same data type in an organized
blondinia [14]

Answer:

NumPy contains a large number of various mathematical operations.

...

Numpy | Mathematical Function.

Function Description

expm1() Calculate exp(x) – 1 for all elements in the array.

exp2() Calculate 2**p for all p in the input array.

log10() Return the base 10 logarithm of the input array, element-wise.

log2() Base-2 logarithm of x.

4 0
3 years ago
3. What is the purpose of the conclusion in an expository essay? (1 point)
Fittoniya [83]
A it makes sense and the conclusion is the wrap up of the essay
7 0
3 years ago
Read 2 more answers
Create the SQL statements for displaying the results for each of the following scenarios in the Academic Database. Save these st
Whitepunk [10]

Answer:

CREATE FUNCTION exam_eligible_students

   RETURN NUMBER AS

   num_students NUMBER(15);

BEGIN

   SELECT COUNT(STUDENT_ID)

   INTO num_students

   FROM STUDENT_ATTENDANCE

   WHERE ELIGIBILITY_FOR_EXAMS = 'Y';

   

   RETURN (num_students);

END;

Explanation:

exam_eligible_students is a made of name for the FUNCTION to be called.

num_students is a made up name for the RETURN to be called. The RETURN name is referenced in the INTO statement and as the name of the the return in the RETURN line in ().

4 0
3 years ago
What is cyber stalking and how does it work?
Tcecarenko [31]
Cyber stalking is when someone stalks them on social media sites like facebook. They try to contact you or will even try to find you.
6 0
3 years ago
Read 2 more answers
Other questions:
  • It is a good idea to use more than one typeface in a document when _____.
    8·2 answers
  • In Microsoft Word, how would you change the amount of space that is put in after each paragraph?
    15·1 answer
  • DJ Davon is making a playlist for an internet radio show; he is trying to decide what 1212 songs to play and in what order they
    12·1 answer
  • It is unlawful in the State of Florida for any person, ______________________, to be a passenger in the front seat of a motor ve
    7·1 answer
  • Which cable would you check if you can't access any web pages?
    12·1 answer
  • What is a cloud in the world of computing
    7·1 answer
  • . Imagine that you were programming without an IDE. What problems might you encounter?​
    12·1 answer
  • The first person to say something in here will get brainliested.
    7·2 answers
  • You have received an update package for a critical application you are running on a virtual machine. You have been told to insta
    8·1 answer
  • Help me with this two questions please
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!