Computer Science, asked by PRADEEPMURMU98, 10 months ago

Write a program to input an integer and check whether it is a 3-digit number or not . If it is , check

whether the sum of first and last digit is even or odd number.​

Answers

Answered by sahupriyanshu710
1

Explanation:

import java.util.Scanner;

public class Prime

{

public static void main (String args[]){

Scanner sc=new Scanner(System.in);

int sum=0;

System.out.println("Enter a number");

int n=sc.nextInt();

if(n>99 && n<1000){

System.out.println("It is a three digit number");

while(n!=0){

int d=n%10;

sum+=d;

n/=100;

}

if(sum%2== 0)

System.out.println("The sum of first and last digit is even ");

else

System.out.println("The sum of first and last digit is odd number");

}

else

System.out.println("It is not a three digit number");

System.out.println("Please enter a three digit number");

}

}

Similar questions