scg/ch10/AddTwoNumbers

From FANG

Jump to: navigation, search

01 package scg.ch10;
02 
03 import java.util.Scanner;
04 
05 /**
06  * Prompt user for two integers. Print the sum of the two integers.
07  * Program then halts.
08  */
09 public class AddTwoNumbers {
10   /**
11    * The main program. Prompt user for two integers and add them
12    * together. DOES NOT WORK AS EXPECTED!
13    *
14    @param  args  command-line arguments; ignored by this program
15    */
16   public static void main(String[] args{
17     System.out.println("AddTwoNumbers:");
18     Scanner keyboard = new Scanner(System.in);
19 
20     System.out.print("Number: ");
21     int first = keyboard.nextInt();
22 
23     System.out.print("Number: ");
24     int second = keyboard.nextInt();
25 
26     System.out.println("Sum of " + first + " + " + second + " = " +
27       first + second);
28   }
29 }
30 
31 //Uploaded on Mon Mar 29 21:41:16 EDT 2010


Download/View scg/ch10/AddTwoNumbers.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games