Write a program to accept a number more than one digit. Then find the sum of all odd digit and product of all even digit.
Urgent Please!!!!!!!!!
Correct Answer I want!!!!!???????
Answers
Answered by
0
Answer:
odd numbers =n² even no.=n(n+1)
Answered by
0
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.print("Enter a number:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int temp = n , evenDigitSum = 0 , oddDigitProduct = 1;
while(temp!=0){
int r = temp%10;
if(r%2 == 0){
evenDigitSum = evenDigitSum + r;
}
if(r%2 == 1){
oddDigitProduct = oddDigitProduct * r;
}
temp/=10;
}
System.out.println("The sum of all even digits in " + n + " is " + evenDigitSum);
System.out.println("The product of all odd numbers in " + n + " is " + oddDigitProduct);
}
}
Explanation:
Similar questions
Computer Science,
9 hours ago
Math,
9 hours ago
Math,
18 hours ago
Chemistry,
18 hours ago
Science,
8 months ago
Science,
8 months ago
Computer Science,
8 months ago