Showing posts with label special-two-digit-number. Show all posts
Showing posts with label special-two-digit-number. Show all posts

Sunday, July 12, 2020

Write a program to input a number and check whether it is Special two digit number or not?(59, 5+9=14, 5*9=45, sum=14+45=59)

46)  Write a program to input a number and check whether it is Special two digit number or not?(59, 5+9=14, 5*9=45, sum=14+45=59)

import java.util.*;
public class Special_two_digit
{
   public static void main(String args[ ])
   {
      Scanner sc = new Scanner (System.in);
      System.out.println("Enter a number");
      int a = sc.nextInt();
      int s = 0;
      int p = 1;
      int k = a;
      if(a>9&&a<100)
      {
          while(k>0)
          {
              int d = k%10;
              s=s+d;
              p=p*d;
              k=k/10;
          }
          int n = s+p;
          if(n==a)
          {
              System.out.println("Entered number is a SPECIAL TWO DIGIT NUMBER ");
          }
          else
          {
              System.out.println("Entered number is not a SPECIAL TWO DIGIT NUMBER");
          }
      }
      else
      {
        System.out.println("Entered number is not a SPECIAL TWO DIGIT NUMBER");
      }
    }
}
 Output :

special-two-digit-number


   Write a program to input a number and find the sum of First and Last digit of this number?(2784=2+4=6first and last digit sum) 


 jhvghvgk ;nkjn ,nkjhj