Professional Documents
Culture Documents
Name:-Nagesh Parab Roll No.: - 07
Name:-Nagesh Parab Roll No.: - 07
Name:-Nagesh Parab Roll No.: - 07
Roll no.:- 07
package exceptions;
import java.util.Scanner;
class validation extends Exception
{
public validation(String str)
{
super(str);
}
}
public class Except
{
public static void validateAge(int age)throws validation
{
if(age<18)
{
throw new validation("Not Valid For Voting.");
}
else
{
System.out.println("You are Validate to Take Degree Education.");
}
}
public static void validateMarrige(int age)throws validation
{
System.out.println("Enter The Gender\n1-Male\n2-Female");
Scanner in=new scanner(System.in);
int gender=in.nextInt();
if((gender==1&&age<21)||(gender==2&&age<18))
{
throw new validation("Not Eligible To Marry.");
}
else
System.out.println("Eligible To Marry.");
}
}
Name :- Nagesh Parab
Roll no.:- 07