Write a Program that dempnstrate program structure of Java


import java.io.*;
public class add1
{
public static void main(String[] s)
{

                                int a,add,b;
                                add=0;
                                String s1,s2;

                                try
                                {
                                DataInputStream d=new DataInputStream(System.in);
                                System.out.println("enter value a & b:");
                                s1=d.readLine();
                                s2=d.readLine();
                                a=Integer.parseInt(s1);
                                b=Integer.parseInt(s2);
                                add=a+b;
                                System.out.println("addition of "+a+" and "+b+"="+add);
                                }
                                catch(Exception e)
                                {
                                                System.out.println("Exception is "+e);
                                }
                                }
}

//output
enter value a & b:
10
12
addition of 10 and 12=22
Press any key to continue . .







No comments:

Post a Comment

We are here to listen you, Comment your valueable opinion...!!!