Q:

Java Branching Statement - if-else statement

0

This Program is used to demonstrate if-else statement concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.io.*; 

class ssvif 
{ 
   public static void main(String arg[]) throws IOException 
    { 
       System.out.print("Enter your age in completed years: "); 

       DataInputStream dr = new DataInputStream(System.in); 

       String t; 

       t = dr.readLine();

       int age = Integer.parseInt(t); 

       if(age >= 18) 
          System.out.println("\nyou are eligible to cast your vote"); 
             else 
         System.out.println("\nyou have to wait for " + (18-age) + " years"); 
    } 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now