using System;
public class ErrorTest
{
public static void Main()
Console.WriteLine("Enter a number for the numerator: ");
string x = Console.ReadLine();
Console.WriteLine("Enter a number for the denominator: ");
string y = Console.ReadLine();
string z = "";
try {
z = divide(x, y);
Console.WriteLine("The result of division is " + z);
}
catch (System.DivideByZeroException dzex) {
Console.WriteLine("Bad input data, do not enter zero for the denominator " + dzex.ToString());
catch(Exception ex) {
Console.WriteLine("Error encountered:: " + ex.ToString());
private static string divide(string x, string y){
int xvalue = Int32.Parse(x);
int yvalue = Int32.Parse(y);
double result = xvalue/yvalue;
string resultvalue = result.ToString();
return resultvalue;