WAP to find the product of three numbers
Answers
import java.util.*;
public class product
{
public static void main (String[]args)
{
Scanner sc = new Scanner (System.in);
int a;
int b;
int c;
int pro;
System.out.println("Enter value of first number :");
a = sc.nextInt();
System.out.println("Enter value of second number :");
b = sc.nextInt();
System.out.println("Enter value of third number :");
c = sc.nextInt();
int pro = a * b * c;
System.out.println("Product of three numbers are: "+pro);
}
}
Enter value of first number :
5
Enter value of second number :
7
Enter value of third number :
8
Enter value of first number :
5
Enter value of second number :
7
Enter value of third number :
8
Product of three numbers are: 280
1.
- Variable name : a
- Data type: int
- Variable Description: to store value of first number .
2.
- Variable name : b
- Data type: int
- Variable Description: to store value of second number .
3.
- Variable name : c
- Data type: int
- Variable Description: to store value of third number .
4.
- Variable name : pro
- Data type: int
- Variable Description: to store product of three numbers.
Answer:
import java.util.*;
public class Numbers
{
public static void main (String[]args)
{
Scanner sc = new Scanner (System.in) ;
System.out.println("Enter three numbers :");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println("Product : "+(a*b*c) );
}
}
Logic:-
- Accept 3 numbers using input
- Simply multiply and print the product