Answer to Question #255557 in Java | JSP | JSF for Rambo

Question #255557
Write a general error handling class that has general functions that would take in a string, which the main pages would get as an input and those functions can search for specific things. Basically an error class for any sort of input from the user where we would expect them to make a mistake.
1
Expert's answer
2021-10-23T13:54:07-0400


class ErrorHandling{
    private int x;
    private int y;
    
    public void setData(int a,int b){
        x=a;
        y=b;
    }
    public void divide(){
        try{
            double div=x/y;
            System.out.println(x+" / "+y+" = "+div);
        }
        catch(Exception e){
            System.out.println("A number cannot be divided by 0");
        }
    }
}
public class Main
{
	public static void main(String[] args) {
		ErrorHandling e=new ErrorHandling();
		e.setData(23,0);
		e.divide();
		e.setData(56,8);
		e.divide();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS