write a program to input a number.Display the product of the successors of even digits of the number entered by user by using scanner.
Answers
Answered by
123
The program is written in Java language and is as follows:
import java.util.*;
public class product
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r,p=1;
System.out.println("Enter a number");
n=sc.nextInt();
while(n!=0)
{
r=n%10;
n=n/10;
if(r%2==0)
{
System.out.println("\n"+"Even digit = "+r);
System.out.println("Its successor = "+(r+1)+"\n");
p = p * (r+1);
}
}
System.out.println("\n"+"The product of successors of the digit is "+p);
}
}
import java.util.*;
public class product
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r,p=1;
System.out.println("Enter a number");
n=sc.nextInt();
while(n!=0)
{
r=n%10;
n=n/10;
if(r%2==0)
{
System.out.println("\n"+"Even digit = "+r);
System.out.println("Its successor = "+(r+1)+"\n");
p = p * (r+1);
}
}
System.out.println("\n"+"The product of successors of the digit is "+p);
}
}
Answered by
18
Explanation:
import java.util.scanner;
{
public static void main ()
{
Scanner sc = new Scanner ( System.in);
int n,r,p=1;
System.out.print("Enter number");
n=sc.nextint();
while(n>0)
{
r=n%10;
n=n/10;
if (r%2==0)
{
p=p*(r+1)
}
}
System.out.println("Product of successors of even digits are "+p);
}
}
Similar questions