//Write a program in Java to accept a number from user and print the digits in Vertically reverse.
import java.util.*;
class GreatestDigit
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r,t;
System.out.print("Enter any number ");
n=sc.nextInt();
t=n;
while(t!=0)
{
r=t%10;
System.out.println(r);
t/=10;
}
}
}
//Write a program in Java to accept a number from user and print the sum of the digits.
import java.util.*;
class GreatestDigit
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r,t;
System.out.print("Enter any number ");
n=sc.nextInt();
t=n;
while(t!=0)
{
r=t%10;
s = s + r;
System.out.println(r);
t/=10;
}
System.out.println("The Sum of Digits is "+s);
}
}
/*Write a program in Java to accept a number from user and print the greatest digit.
For example 37825
The greatest digit is 8
*/
import java.util.*;
class GreatestDigit
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r,t,g=0;
System.out.print("Enter any number ");
n=sc.nextInt();
t=n;
while(t!=0)
{
r=t%10;
if(r>g)
g=r;
t/=10;
}
System.out.println("The Greatest Digits is " + g);
}
}
/*Write a program in Java to accept a number from user and print the number as a Reverse Whole number.
[Input: 123 (One Hundred Twenty Three)
Output: 321 (Three Hundred Twenty One)]
Note: You don't need to print the number in Words.
*/
import java.util.*;
class ReverseWholeNumber
{
public static void main()
{
int n,r=0,t,rev=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter Any Number: ");
n=sc.nextInt();
t=n;
while(t!=0)
{
r=t%10;
rev = rev*10 + r;
t=t/10;
}
System.out.println("The Original Number is " + s);
System.out.println("The Reversed Number is " + rev);
}
}
/*A special two-digit number is such that when the sum of the digits is added to the product of its digits, the result is equal to the original two-digit number.
Example:
Consider the number 59.
Sum of digits = 5+9=14
Product of its digits = 5 x 9 = 45
Sum of the digits and product of digits = 14 + 45 = 59
*/
import java.util.*;
class SpecialTwoDigitNumber
{
public static void main()
{
int n,r=0,t,s=0,p=1;
Scanner sc=new Scanner(System.in);
System.out.print("Enter Any Number: ");
n=sc.nextInt();
t=n;
while(t!=0)
{
r=t%10;
s = s + r;
p = p * r;
t=t/10;
}
if((s+p)==n)
System.out.println("It is a special two-digit number ");
else
System.out.println("It is not a special two-digit number ");
}
}