public class Product
1: // Ex. 2.6: Product.java
2: // Calculate the product of three integers.
3: import java.util.Scanner; // program uses Scanner
4:
5: public class Product
6: {
7: public static void main( String args[] )
8: {
9: // create Scanner to obtain input from command window
10: Scanner input = new Scanner( System.in );
11:
12: int x; // first number input by user
13: int y; // second number input by user
14: int z; // third number input by user
15: int result; // product of numbers
16:
17: System.out.print( "Enter first integer: " ); // prompt for input
18: x = input.nextInt(); // read first integer
19:
20: System.out.print( "Enter second integer: " ); // prompt for input
21: y = input.nextInt(); // read second integer
22:
23: System.out.print( "Enter third integer: " ); // prompt for input
24: z = input.nextInt(); // read third integer
25:
26: result = x * y * z; // calculate product of numbers
27:
28: System.out.printf( "Product is %d\n", result );
29:
30: } // end method main
31:
32: } // end class Product
33:
34:
35: /**************************************************************************
36: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
37: * Pearson Education, Inc. All Rights Reserved. *
38: * *
39: * DISCLAIMER: The authors and publisher of this book have used their *
40: * best efforts in preparing the book. These efforts include the *
41: * development, research, and testing of the theories and programs *
42: * to determine their effectiveness. The authors and publisher make *
43: * no warranty of any kind, expressed or implied, with regard to these *
44: * programs or to the documentation contained in these books. The authors *
45: * and publisher shall not be liable in any event for incidental or *
46: * consequential damages in connection with, or arising out of, the *
47: * furnishing, performance, or use of these programs. *
48: *************************************************************************/