import java.io.*;
class Xylem
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("N = ");
int num = Math.abs(Integer.parseInt(br.readLine()));
int extreme = 0;
int mean = 0;
int copy = num;
while(copy != 0)
{
if(copy == num || copy < 10)
extreme += copy % 10;
else
mean += copy % 10;
copy /= 10;
}
System.out.println("Sum of extreme digits: " + extreme);
System.out.println("Sum of mean digits: " + mean);
if(extreme == mean)
System.out.println(num + " is a xylem number.");
else
System.out.println(num + " is a phloem number.");
}
}
No comments:
Post a Comment
any problem in any program comment:-