Java code to Format the given Integer Value
public class FormatIntValue
{
public static void main(String[] args)
{
int num = 5245;
int position = 1;
String outString = "";
String tempString = "";
while(true)
{
tempString = outString ;
outString = "";
outString += (num%10) * position;
position *= 10;
num /=10;
if (position != 10)
outString += "+";
outString += tempString;
if (num < 10)
break;
}
tempString = outString;
outString = "";
outString += (num)*position;
outString += "+";
outString += tempString;
System.out.println(outString);
}
}
public class FormatIntValue
{
public static void main(String[] args)
{
int num = 5245;
int position = 1;
String outString = "";
String tempString = "";
while(true)
{
tempString = outString ;
outString = "";
outString += (num%10) * position;
position *= 10;
num /=10;
if (position != 10)
outString += "+";
outString += tempString;
if (num < 10)
break;
}
tempString = outString;
outString = "";
outString += (num)*position;
outString += "+";
outString += tempString;
System.out.println(outString);
}
}
No comments:
Post a Comment