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:

Arbitrage Profit

The profit realized from exploiting the price difference of the same or similar financial instruments on different markets or in different forms.

Stock Index

A statistical measure which tracks the performance of a basket of stocks, representing a segment of the stock market.

T-bond Futures

Futures contracts that obligate the buyer to purchase U.S. Treasury bonds at a specified price at a future date, used for hedging and investing purposes.

Issuing Bonds

The process by which corporations or governments raise capital by selling debt securities, promising to repay the principal amount with interest at a later date.

Related Questions