Search This Blog

Wednesday 13 July 2022

1. NEP Java Program to find the sum of two integers and float numbers. Read through Command Line.

//1. NEP Java Program to find the sum of two integers and //float numbers.

import java.io.*;

class Program11

{   

     public static void main(String args[])throws IOException

     {

          int a=10,b=20;

          float c=40.2F,d=35.5F;

 

          try

          {

                   a=Integer.parseInt(args[0]);

                   b=Integer.parseInt(args[1]);

                    c=Float.parseFloat(args[2]);

                   d=Float.parseFloat(args[3]);

          }

          catch(Exception e){}

          System.out.println(a + " " + b + " " + c + " " + d);

 

          add(a,b);

          add(c,d);

  

          int sum = a + b;

 

     }

     public static void add(int a, int b)

     {

          int sum = a+b;

          System.out.println("The sum is: " + sum);

     }

     public static void add(float c, float d)

     {

          float sum = c+d;

          System.out.println("The sum is: " + sum);

     }

}

No comments :

Post a Comment

FREE Hit Counters