write a program in Java where to create names some of digit a function while using a number through parameter and return the sum of digit now create a main function to accept a number from the user and check whether the number is neon number or not even number or not
Answers & Comments
Verified answer
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
//To take input from the user
//Create an object of scanner class
Scanner input = new Scanner(System.in);
int num; //Declare a variable
System.out.println("Enter a number:");
num = input.nextInt();
//If number is divisible by 2 then it's an even number
//else odd number
if ( num % 2 == 0 )
System.out.println("The entered number is even");
else
System.out.println("The entered number is odd");
}
}