CONCATENATE OF TWO NUMBERS
In this program we learn how to concatenate of two numbers by provided user using Java.Java program to concatenate of two numbers
// CONCATENATE OF TWO NUMBERS
import java.util.*;
import java.lang.*;
class Concatenate
{
int a, b;
public
Concatenate()
{
Scanner in = new Scanner(System.in);
System.out.print("\n Enter two numbers : ");
a = in.nextInt();
b = in.nextInt();
}
int joined()
{
double c, i = 0;
int n;
c = a;
n = b;
do
{
n = n / 10;
i++;
}while(n != 0);
a = (int)(c * Math.pow(10, i)) + b;
return(a);
}
void display(int p)
{
System.out.print("\n The concatenate number = "+p);
}
public static void main(String arg[])
{
Concatenate s = new Concatenate();
int p;
p = s.joined();
s.display(p);
}
};
OUTPUT:
Enter two number : 25 23
The concatenate number = 2523
The concatenate number = 2523
No comments:
Post a Comment