Write a program that reads integers userNum and divNum as input, and output the quotient (userNum divided by divNum). Use a try block to perform the statements. Use a catch block to catch any ArithmeticException and output an exception message with the getMessage() method. Use another catch block to catch any InputMismatchException and output an exception message with the toString() method. Note: ArithmeticException is thrown when a division by zero happens. InputMismatchException is thrown when a user enters a value of different data type than what is defined in the program. Do not include code to throw any exception in the program.

Answers

Answer 1

The program is an illustration of exceptions

Exceptions are used to manage programs from crashing, when they encounter errors.

The program in Java, where comments are used to explain each line is as follows:

import java.util.*;

public class Main {

   public static void main(String[] args) {

       //This creates a Scanner object

       Scanner input = new Scanner(System.in);

       //This gets input for userNum

       int userNum = input.nextInt();

       //This gets input for divNum

       int divNum = input.nextInt();

       //This opens the InputMismatchException try catch

       try {

           //This opens the ArithmeticException try catch

           try{

               //This prints the division of userNum by divNum

               System.out.print(userNum/divNum);

           }

           //If divNum is 0, this catches the exception

           catch (ArithmeticException e){

               System.out.println(e.getMessage());

           }  

        }  

        //If the inputs are not integers, this catches the exception

        catch (InputMismatchException ex) {

           System.out.println(ex.getMessage());

        }

  }

}

Read more about exceptions at:

https://brainly.com/question/6864640


Related Questions

people, hardware, software, data, procedures, and communication network working together to collect, transform and disseminate information called

Answers

Answer:

Information systems are combinations of hardware, software, and telecommunications networks that people build and use to collect, create, and distribute useful data, typically in organizational settings.

Explanation:

Sonia is configuring a RAID level 5 array with five disks. Each disk has the capacity to store 3 TB of data. What is the total storage size that Sonia can use to store data

Answers

RAID describes a set of disk arrays used for creating data storage in computer machines. The Fraction of the space allocated for redundancy usually depends on the number of disk arrays. Hence, the usable amount of storage available is 12 TB.

The RAID level 5 array describes here has 5 disks which can be represented as n.

The Fraction of allocated storage would be 1/n. Hence, the allocated storage here for each of the 5 disks would be 1/5 × 3 = 0.6 TB.

Amount of usable storage per disk would be :

3TB - 0.6TB = 2.4TB

Total usable storage = 2.4 TB × 5 = 12 TB

Hence, 12 TB of storage can be used by Sonia.

Learn more : https://brainly.com/question/25646541

True or False: A sequential search of a list assumes that the list elements are sorted in ascending order.

Answers

True in the answer
Hope this helps

please help me asapppppp​

Answers

Answer:

lol no

Explanation:

Each slide in a presentation has a layout that includes placeholders for certain types of content?
True
False

Answers

Answer:

True

Explaination:

It has layouts that includes placeholders for images, text and lot more

Each slide in a presentation contains a layout that includes placeholders for certain types of content: True.

What is a slide?

A slide simply refers to a single page of a presentation that comprises text-based information or images, which can be used to teach, instruct and educate the audience on a subject matter, topic, event or idea.

In Computer technology, each slide in a presentation contains a layout that includes placeholders for certain types of content such as:

ImagesTextsVideo

Read more on slides here: https://brainly.com/question/26187618

#SPJ2

What aligns the touch and display layers of a touch screen to ensure accurate input? I know the word starts with C has a I and T like this C . . i . . . t . . .

Answers

Ans

I think is Capacitive

Explanation:

Dude I think I forget. I remember how it work but I for get it's name I think is

Capacitive

name the steps to turn on a computer properly​

Answers

Answer:

Check that the computer is connected to power, and is powered on.

Make sure that your keyboard and mouse are plugged in.

Check that the monitor (screen) is plugged into the computer using its display cable.

Ensure that the monitor is connected to power and is turned on.

Explanation:

what is the basic computer application?​

Answers

Answer:

a computer code

Explanation:

fhfdgkykd

What is the output of the following code?
print (12 // 6)

Answers

Answer:

2

See here we have //// means floor division in python.It gives us only the integer part not floating or decimal.

So

12//6=2

All of the following is true about an artificial neural network, or ANN except: a.It identifies patterns that have not been programmed b.It is an optimization tool c.It is a computer system that can recognize and act on patterns or trends it detects in large sets of data d.It functions similarly to the neural circuitry of the brain

Answers

Answer:

b. It is an optimization tool

Explanation:

All of the following are true about an artificial neural network, or ANN except:

B. It is an optimization tool

According to the given text, we are asked to show the odd one out about the artificial neural network or ANN and its functions in the computer network

As a result of this, we can see that the artificial neural network or ANN helps to identify patterns that have not been programmed, functions similarly to the neural circuitry of the brain, recognizes and acts on patterns or trends it detects in large sets of data, but it is not an optimization tool.

Therefore, the correct answer is option B

Read more here:

https://brainly.com/question/19714088

Background information: This is an excerpt from a 1433 speech by Emperor Zhu Di.

Due to so many unexplained difficulties and bad omens, the Majesty is humbled and concerned. . . . To alleviate the situation, all policies that cause the public inconvenience, if not urgent, should be stopped. . . . Policies temporarily stopped include the voyages to foreign countries, horse trading with the remote western and northern areas.

What Ming political and economic policy does this excerpt provide an example of?

commercialism
Confucianism
kowtowing
isolationism

Answers

Answer:

D. isolationism

Explanation:

What critical-thinking tool is being used when asking the question, "Is there a large enough scope of
information?"
O synergy
O breadth
O semantics
O depth

Answers

Answer:

breadth

if I am correct.

**IN PYTHON**
Write a program that uses a loop and a half to prompt a user for a password. You should prompt the user for the password. If they get it correct, break out of the loop. If they don’t get it correct, you should give them an error message and ask again.

Sample Run:
Enter password: 123123
Sorry, that did not match. Please try again.
Enter password: password
Sorry, that did not match. Please try again.
Enter password: CODEHS
Sorry, that did not match. Please try again.
Enter password: abc123
You got it!
Note: You need to set SECRET to abc123 to run the tests

Answers

Answer:

SECRET = "abc123"

while True:

p = input("Enter password: ")

if p != SECRET:

 print("Sorry, that did not match, Please try again.")

else:

 print("You got it!")

 break

Explanation:

SECRET = "abc123" will be used in the language of python that was created.

What is Python?

Python is a PC programming language frequently used to fabricate sites and programming, robotize errands, and direct information examination. Python is a universally useful language. This language tends to be utilized to make a wide range of projects and isn't particular for a particular issue.

To maintain a user attempting to enter the password, we have used a while loop that never ends. We employ an if-else structure in the loop to determine the password. If it is "abc123," the passcode is discovered, and the loop is broken.

SECRET = "abc123"

There is a function and if that is true, then

p = input("Enter password: ")

The if function will be implemented.

if p != SECRET:

print("Sorry, that did not match, Please try again.")

The else function will be implemented:

else:

print("You got it!")

break

Learn more about Python, here:

https://brainly.com/question/30427047

#SPJ3

Has digital transmission changed the nature of communication?

Answers

Answer:

yes , digital transmission really has changed the communication with the new apps and devices and reduced paper work.

How do i find the minterms

Answers

Answer:

I think.....

Explanation:

bylooking

How do you code in computers and technology

Answers

Take online courses.

Watch video tutorials.

Read books and ebooks.

Complete coding projects.

Find a mentor and a community.

Consider enrolling in a coding boot camp.

state the differences between selecting a text and highlighting a text as used in computing​

Answers

Explanation:

The difference between highlighting the text and selecting the text is highlighting is when you change the highlight/back color of the text and selecting is when you temporarily highlight it to change a certain part

Problem Statement − Suppose the problem statement at hand is to contain the attrition that happens in companies worldwide. High quality employees leave the organization, mainly after the appraisal cycle. As a result, an average company loses its valuable human resources and suffers from an overhead of transferring the knowledge to a new employee. This takes time and additional human resource in the form of a trainer, which adds to the company’s costs. Devise a plan to contain attrition in the company.

Answers

Answer:Analysis is derived from the Greek word ‘analusis’, which translates into ‘breaking up’ in English. Analysis is older than the times of great philosophers like Aristotle and Plato. As discussed in the previous section, analysis is the process of breaking down a big single entity into multiple fragments. It is a deduction where a bigger concept is broken down to smaller ones. This breaking down into smaller fragments is necessary for improved understanding.

So, how does analysis help in design thinking? During analysis, design thinkers are required to break down the problem statement into smaller parts and study each one of them separately. The different smaller components of the problem statement are to be solved one-by-one, if possible. Then, solutions are thought for each of the small problems. Brainstorming is done over each of the solutions.

Later, a feasibility check is done to include the feasible and viable solutions. The solutions that don’t stand firm on the grounds of feasibility and viability are excluded from the set of solutions to be considered.

Design thinkers are, then, encouraged to connect with the diverse ideas and examine the way each idea was composed. This process of breaking down the bigger problem statement at hand into multiple smaller problem statements and examining each as a separate entity is called analysis.

Reductionism

The underlying assumption in analysis is reductionism. Reductionism states that the reality around us can be reduced down to invisible parts. The embodiment of this principle is found in basic axioms of analytic geometry, which says “the whole is equal to the sum of its parts”. However, understanding of a system cannot be developed by analysis alone. Hence, synthesis is required following analysis.

Synthesis

Synthesis refers to the process of combining the fragmented parts into an aggregated whole. It is an activity that is done at the end of the scientific or creative inquiry. This process leads to creation of a coherent bigger entity, which is something new and fresh. How does synthesis come into picture in design thinking?

Once the design thinkers have excluded the non-feasible and non-viable solutions and have zeroed-in on the set of feasible and viable solutions, it is time for the thinkers to put together their solutions.

Out of 10 available solutions, around 2-3 solutions may need to be excluded since they may not fit into the larger picture, i.e. the actual solution. This is where synthesis helps.

The design thinkers start from a big entity called the problem statement and then end up with another bigger entity, i.e. the solution. The solution is completely different from the problem statement. During synthesis, it is ensured that the different ideas are in sync with each other and do not lead to conflicts.

Analysis + Synthesis = Design Thinking

Analysis and synthesis, thus, form the two fundamental tasks to be done in design thinking. Design thinking process starts with reductionism, where the problem statement is broken down into smaller fragments. Each fragment is brainstormed over by the team of thinkers, and the different smaller solutions are then put together to form a coherent final solution. Let us take a look at an example.

Analysis Synthesis

Case Study

Problem Statement − Suppose the problem statement at hand is to contain the attrition that happens in companies worldwide. High quality employees leave the organization, mainly after the appraisal cycle. As a result, an average company loses its valuable human resources and suffers from overhead of transferring the knowledge to a new employee. This takes time and additional human resource in the form of a trainer, which adds to the company’s costs. Devise a plan to contain attrition in the company.

Analysis − Now, let’s break down the problem statement into various constituent parts. Following are the subparts of the same problem statement, broken down to elementary levels.

The employees are not motivated anymore to work in the company.

Appraisal cycle has something to do with attrition.

Knowledge transfer is necessary for new employees.

Knowledge transfer adds to the cost of the company.

Synthesis − Now, let's start solving each problem individually. In this step, we will do synthesis. Let's look at one problem at a time and try to find a solution only for that problem statement, without thinking of other problem statements.

Explanation:

The agreement must be signed by the employee before giving appraisal letter and in that there is some time limit that is essential to be in the organization.

Why employee leaves the company after getting appraisal?

The employees leave the old company after getting the promotion or appraisal letter from the authority because they want to get the better salary by showing the apparent post in the old organization. They get better salary from the last job.

Thus, The agreement must be signed by the employee before giving appraisal letter

For more details about employee leaves the company after getting appraisal, click here:

https://brainly.com/question/14057221

#SPJ2

Prior to the invention of the WIMP interface, users often interacted with systems through _____ interfaces. Group of answer choices Audio Touch Command-based GUI

Answers

Answer:

comment Line Interface

(the command-based option)

Explanation:

Not an expert so the answer might be wrong

Prior to the invention of the WIMP interface, users often interacted with systems through command-line interfaces. Thus, the correct option is C.

What is Command Line Interface?

A command-line interpreter or command-line processor is the device and expert who uses a command-line interface to receive all the commands from a user in the form of lines of texts. This command provides a means of setting parameters for the environment, including invoking of the executables and providing information to them as to what actions they are required to perform.

User interfaces are the commands which may be of three types including command line interface, graphic user interface, and menu-driven interface. Programmers, experienced computer users, or administrators are the people who may utilize a command line interface.

Therefore, the correct option is C.

Learn more about Command-line interface here:

https://brainly.com/question/15704118

#SPJ2

Creation of network is known as…?

Answers

Answer:

GRID

Explanation:

HOPE IT HELP ✌️✌️✌️✌️

Answer:

It’s knows as grid

Explanation:

creation of network is known as grid

(Hope this helps can I pls have brainlist (crown)☺️)

what is the principal goal of data science?​

Answers

Answer:

Hi

The principal goal of data science is to construct the means for extracting business-focused insights from data. This requires an understanding of how value and information flows in a business, and the ability to use that understanding to identify business opportunities.

Explanation:

If it's help pls give a

Use Chrome Remote Desktop to create a remote connection to Computer 2. Can you use the utility to view the desktop of Computer 2

Answers

Answer:

Yes, this can be done. You'll need a static IP on your desktop, there is a registry entry that controls the port remote desktop listens on. Change the desktop to port 3390 or some other unused port number.

What practice makes it virtually impossible to figure out the geographic location of a company?
O virtual location
O multiple location
O cloud location
O colocation

Answers

Virtual Location because then they think it’s landlocked even if it’s not or it’s islands even if it’s just mainland

Consider rolling a 6-sided die. The outcome of interest is the number of dots that appears on the topside when the die stops rolling. The possible outcomes are 1, 2, 3, 4, 5 & 6. Suppose we play the following game. Roll the 6-sided die, you are rewarded a dollar amount equal to the number of dots on the topside of the die when it comes to rest. Suppose the die is fair (each side is equally likely). Define the random variable X to be the amount you are rewarded after one roll.

Answers

Using the discrete probability relation, the random variable, X for the amount to be rewarded per roll is :

X : ___ 1___ 2 ___ 3 ___ 4 ___ 5 ___6P(X)__1/6__ 1/6 __ 1/6__ 1/6___ 1/6 _ 1/6

The dollar amount corresponds to the number on the die :

Possible amount awarded (X) :

X = {1, 2, 3, 4, 5, 6}

Since we have a fair die :

Probability of obtaining any certain value on the die is the same ; Hence, the probability of obtaining a certain value would be :

P = 1/6

Hence, the random variable, X can be defined thus:

X : ___ 1___ 2 ___ 3 ___ 4 ___ 5 ___6

P(X)__1/6__ 1/6 __ 1/6__ 1/6___ 1/6 _ 1/6

Learn more : https://brainly.com/question/25341513

Following program use in coding

Answers

Hmmmmmm..... I think its java if I'm correct

What are the 3 dimension of an information system?

Answers

Answer:

There are three dimensions of information systems ; organizational, management, and technology. Senior management always make decisions, so senior management is required to understand these three dimensions to make better decisions of the business through information systems.

explain why the database system would not allow a tuple to be inserted into the database through this view

Answers

For the view of Exercise 4.18, explain why the database system would not allow a tuple to be inserted into the database through this view.
For reference
For the database of Figure 4.12, write a query to find the ID of each employee with no manager. Note that an employee may simply have no manager listed or may have a null manager. Write your query using an outer join and then write it again using no outer join at all.
OUTER JOIN
select e.ID from employee e left outer join manages m on e.ID = m.ID
where m.manager_id is null;
NO OUTER
select e.ID from employee e where e.ID not in (select m.ID from manages m) or e.ID in (select m.ID from manages m where m.manager_id is null);

The database system would not allow a tuple to be inserted into the database through this view because it is  not compatible.

What is compatibility?

The term to be compatible is one where two or more things can work together and not have issues.

Note that in the above scenario, The database system would not allow a tuple to be inserted into the database through this view because it is  not compatible.

Learn more about database from

https://brainly.com/question/26096799

#SPJ2

Roz’s teacher says that the assignment for that day is to listen to a speech by President Kennedy. Which of the following files will Robin open to complete the assignment? A. PDF B. docx C. mp3 D. systems software

Answers

Answer:

Pretty sure the answer is C. mp3

Explanation:

They have to listen to the speech, not read it or anything, and mp3's are audio files. Hope this helps :D

Answer:

c

Explanation:

source: trust me bro

Clock speed of the first generation of a computer

Answers

Answer:

2 million cycles per second

Explanation:

The ENIAC, the first electronic general-purpose computer, used a 100 kHz clock in its cycle unit. It had a 5 kHz instruction rate since each instruction required 20 cycles. The Altair 8800 (by MITS) was the first commercial PC to use an Intel 8080 CPU with a clock rate of 2 MHz (2 million cycles per second).

What does marking something as brainliest do?

im just wondering its not urgent

Answers

Answer:

it helps people level up on brainlly

Answer:

I think it gives you extra points and gives you more stats overall.

Explanation:

Other Questions
1. Looking after the passengers on the flight is the task of the . a. air-hostess b. cook c. servant d. waitress What was created that broke down the electoral system in the election of 1800? 5/8x -3/5=??????????????????????????????????????? Can someone please write me a well written paragraph on living in a house vs a apartment 6m - 7: m = 12Plsss helppp What centuries is the Renaissance usuallyassociated?18th century16th century17th century15th century FIRST ANSWER GETS BRAINLIEST!!!!How could you create or design a new calendar? What would you think about when developing anew type of calendar? Explain your thinking. How have vaccines impacted health? Many deadly diseases have been almost eliminated. Vaccines have only made a little progress at preventing most diseases. Large numbers of people have had allergic reactions to vaccines. Vaccines are effective, but only when given to children. Two lines are perpendicular if they lie on the same plane and cross at_____ angles. (FILL IN THE BLANK) What is Motion???????????? which branch of government applies the law based on certain situations Why can videos be streamed from one computer to another with excellentquality?A. They are received using either analog or digital signals.B. They are transmitted using digital signals.C. They are transmitted using analog signals.D. They are received using both analog and digital signals.SUBMIT Technician A says that electronic conductance testing can determine CCA, state-of-charge, and voltage of the battery. Technician B says that electronic conductance testing determines if there is a bad cell and the battery is not serviceable and should be replaced. Which technician is correct How did life change for American Indian groups of the Great Plains when European settlers introduced horses to the area Can someone please quickly answer this question?Does it matter the order for an electronic configuration? So, like for the electronic configuration of Tin, can I either use [Kr]4d^105s^25p^2 or [Kr]5s^24d^1050^2Im just confused, when I look it up they show both so I dont know which one is correct so I can use for my lab report? 14) What is 56% of 125? help please i need answer asap!! Geometry B: fill in the blank Can you help me with my homework please? I don't understand where to dispose of old fire extinguishers near me