Saturday, September 5, 2015

Product of Two Numbers Using Scanner in Java

In this article I would like to share with you a sample program that will compute the product of two numbers using scanner library in Java. The code is very easy to understand and use in this program I am using Eclipse as my integrated development environment.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.




Sample Program Output

Program Listing

package demo;

import java.util.Scanner;

public class Demo {
 public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Product of Two Numbers");
System.out.print(" Enter first value : ");
int val1 = scan.nextInt();
System.out.print(" Enter second value : ");
int val2 = scan.nextInt();
int product = val1 * val2;
System.out.print("The product of "+ val1  + " and " 
+ val2 + " is " + product + ".");
     } 
 

}





No comments:

Post a Comment