Program 3 : Addition of 2 integer number which is given by the user using command line window.

Program : 
Create a Java Program that make the Addition of 2 integer number which is given by the user using command line window.

Solution :

class SabTech
{
public static void main(String args[])
    {
if(args.length!=2)
{
System.out.println("Not enough arguments...Please Pass Exactly TWO arguments...");
System.exit(0);
}
int no1=Integer.parseInt(args[0]);
int no2=Integer.parseInt(args[1]);
int ans;
ans=no1+no2;
System.out.println("Addition of " + no1 + " and " + no2 + " is ==> " + ans);
}
}

O/P:
>javac SabTech.java
>java SabTech 15 12

Addition of 15 and 12 is ==> 27

Comments

Popular posts from this blog

Part 1: Introduction to Bigdata

Maths for Machine Learning

Good news for SAP Developers, SAP not cutting jobs in India but Creating more Jobs in India.