import java.util.*;
class OddException extends Exception
{
public OddException(String s)
{
super(s);
}
}
public class pro34
{
public static void main(String ar[])
{
int tep=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter how many number u want to enter");
int size=sc.nextInt();
int a[]=new int[size],i;
for(i=0;i<size;i++)
{
a[i]=sc.nextInt();
try
{
if(a[i]%2==0)
{
}
else
{
tep++;
throw new OddException("plzz do not enter a odd numbers");
}
}
catch(OddException e)
{
System.out.println(e.getMessage());
}
}
System.out.println("odd numbers are = "+tep);
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.