import java.io.*; // import java.lang.*; /* Sample application: enter 10 integer values (on the command line) and print their sum and their product Compiler: javac Sample2.java Run: java Sample2 */ public class Sample2 { // This is the starting point for the execution of the program public static void main(String[] args) throws IOException { // we declare some variables that we need later int sum, product, i, number; // we generate an input stream, reading from the keyboard BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); // we generate an output stream, writing to the console PrintWriter screen = new PrintWriter(System.out, true); // initialise the aggregate sum variable sum = 0; product = 1; // iterate 10 times for (i = 0; i<10; i=i+1) { screen.print("Enter an integer: "); screen.flush(); number = Integer.parseInt(keyboard.readLine().trim()); sum = sum + number; product = product * number; } screen.println("Sum = " + sum + ";\t Product = " + product); } }