Arithmetic Exception

 MAIN.JAVA:

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// your code here
		Scanner sc = new Scanner(System.in);
	
	
		System.out.println("Enter the cost of the item for n days");
		int costPerItem = sc.nextInt();
		System.out.println("Enter the value of n");
		int n = sc.nextInt();
		try {
			int k = costPerItem/n;
            System.out.println("Cost per day of the item is "+k);
		}
		catch(Exception e) {
			 System.out.println("java.lang.ArithmeticException: "+e.getMessage());
		}
	}

}
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.