// Sums.java Copyright (c) 2005 Kari Laitinen // Note that is different program than Sum.java // which is discussed at the beginning of the book. // So if you by accident found this program while // trying to find Sum.java, keep searching. This is // not the correct program if you are beginning // your studies. // http://www.naturalprogramming.com // 2004-10-09 File created. // 2005-02-05 Last modification. import java.util.* ; class Sums { static void print_sum( int first_integer_from_caller, int second_integer_from_caller ) { int calculated_sum ; calculated_sum = first_integer_from_caller + second_integer_from_caller ; System.out.print( "\n The sum of " + first_integer_from_caller + " and " + second_integer_from_caller + " is " + calculated_sum + ".\n" ) ; } public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; print_sum( 555, 222 ) ; System.out.print( "\n As you can see, this program can print" + "\n the sum of two integers. Please, type in" + "\n two integers separated with a space:\n\n " ) ; int first_integer = keyboard.nextInt() ; int second_integer = keyboard.nextInt() ; print_sum( first_integer, second_integer ) ; } } /* <- This character pair (a slash and an asterisk) starts a multiline comment. The multiline comment ends when these characters are encountered in the opposite order, i.e., an asterisk precedes a slash. NOTE: An alternative implementation of the main() method is the following: public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; print_sum( 555, 222 ) ; System.out.print( "\n As you can see, this program can print" + "\n the sum of two integers. Please, type in" + "\n the first integer: " ) ; int first_integer = keyboard.nextInt() ; System.out.print( "\n And now the second integer: " ) ; int second_integer = keyboard.nextInt() ; print_sum( first_integer, second_integer ) ; } } *****/