# Product of first and last digit in Java

###### Input - Question 6

In this question, we will see how to input a three digit number in Java programming using the java input and find the product of its first and last digit. To know more about java input click on the java input lesson.

**Q6)** Write a program in Java to input a three digit number and find the product of its first and last digit.

#### Program

```
import java.util.Scanner;
public class Q6
{
public static void main(String args[])
{
int n,fd,ld,pr;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a three digit number");
n=sc.nextInt();
fd=n/100;
ld=n%10;
pr=fd*ld;
System.out.println("First digit=" + fd);
System.out.println("Last digit=" + ld);
System.out.print("Product of first and last digit=" + pr);
}
}
```

#### Output

Enter a three digit number 854 First digit=8 Last digit=4 Product of first and last digit=32