23) Write a java program that reads line of integers. Display each integer and also display sum of all integers


import java.io.*;
class SumInt
{
public static void main(String args[])throws IOException
{
long sum=0;
String i=””;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter Line of Integer”);
long str=Long.parseLong(br.readLine());

while(str>0)
{
i=i+””+str%10;
sum=sum+str%10;
str=str/10;
}
System.out.println(“All integer Degits :-> “);
for(int k=i.length()-1;k>=0;k–)
{
System.out.println(i.charAt(k));
}
System.out.println(“Summation of all integer Degits :-> “+sum);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s