00:00
L38vOTE.png
import java.util.Scanner; class YoungerAgeException extends RuntimeException{ YoungerAgeException(String msg){ super(msg); } } class L38vOTE{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("enter your age"); int age = sc.nextInt(); if(age<18){ throw new YoungerAgeException("you are not elligible for voiting"); } else{ System.out.println("you can vote"); } System.out.println("voting process done successfully"); } } /* ramannegi@Ramans-MacBook-Pro x % javac L38vOTE.java ramannegi@Ramans-MacBook-Pro x % java L38vOTE enter your age 21 you can vote voting process done successfull */
Home PREVIOUS NEXT