import java.io.*;
class add
{
int no,rem;
add(int n,int sum)
{
no=n;
while(no!=0)
{
rem=no%10;
sum=sum+rem;
no=no/10;
}
System.out.println(n+" of digits sumssion is = "+sum);
}
}
class parameterised_constructer_sum_of_digit
{
public static void main(String args[])
{
int n,sum=0;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter the number to calculate its sum of digits");
n=Integer.parseInt(cin.readLine());
add a=new add(n,sum);
}
catch(Exception e)
{
System.out.println("Wrong data");
}
}
}
class add
{
int no,rem;
add(int n,int sum)
{
no=n;
while(no!=0)
{
rem=no%10;
sum=sum+rem;
no=no/10;
}
System.out.println(n+" of digits sumssion is = "+sum);
}
}
class parameterised_constructer_sum_of_digit
{
public static void main(String args[])
{
int n,sum=0;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter the number to calculate its sum of digits");
n=Integer.parseInt(cin.readLine());
add a=new add(n,sum);
}
catch(Exception e)
{
System.out.println("Wrong data");
}
}
}
No comments:
Post a Comment