Examlex

Solved

Import Java.util.*; Public Class DivisionMistakeCaught3

question 64

Essay

import java.util.*;
public class DivisionMistakeCaught3
{
    public static void main(String[] args)
    {
       Scanner input = new Scanner(System.in);
       int numerator, denominator, result;
       try
       {
          System.out.print("Enter numerator >> ");
          numerator = input.nextInt();
          System.out.print("Enter denominator >> ");
          denominator = input.nextInt();
          result = numerator / denominator;
          System.out.println(numerator + " / " + denominator + " = " + result);
       }
       catch(ArithmeticException mistake)
       {
          System.out.println(mistake.getMessage());
       }
       catch(InputMismatchException mistake)
       {
          System.out.println("Wrong data type");
       }  
    }
}
Using the above code, describe what will happen if a user enters two usable integers. What will happen if a user enters an invalid noninteger value? What will happen if the user enters 0 for the denominator?


Definitions:

Quantity Purchased

The total number of units of a product or service bought by consumers in a specified period.

Price Elasticity

The evaluation of demand's reaction to fluctuations in the price of a particular good.

Responsiveness

The degree to which a variable responds to a change in an underlying factor, often used in economic contexts to describe changes in supply, demand, price, etc.

Price Elasticity

A measure of how much the quantity demanded or supplied of a product changes in response to a change in its price.

Related Questions