Computer Science, asked by rajdeepdash2006, 7 months ago

Write a java 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 an Odd number.​

Answers

Answered by malugedam2
1

Answer:

Java program to check whether a number is even or odd; if it's divisible by two, then it's even, otherwise, odd. We use the modulus operator to find the remainder. For an even number, it's zero when it's divided by two (it's one for an odd number).

Answered by darkghost486
13

Answer:

import java.util.Scanner;

class sum

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

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

int n=sc.nextInt();

int num=n,d,sum=0,c=0,a,b;

while(n!=0)

{

d=n%10;

c++;

n=n/10;

}

if(c==3)

{

System.out.println("A three digit no.");

a=num%10;

num=num/10;

b=num/10;

System.out.println("Sum of first and last digit="+(a+b));

}

else

System.out.println("Not a three digit no.");

}

}

Similar questions