intro/ConsoleOrParameter

From ggc

Jump to: navigation, search

01 package intro;
02 //start auto-imports
03 import java.util.*;
04 //end auto-imports
05 
06 
07 /**
08  * All about my application.
09  @author Jam
10  */
11 public class ConsoleOrParameter
12 {
13   public void add()
14   {
15     Scanner scanner=new Scanner(System.in);
16     System.out.println("Enter the first integer.");
17     int x=scanner.nextInt();
18     System.out.println("Enter the second integer.");
19     int y=scanner.nextInt();
20     int z=x+y;
21     System.out.println("The result is "+z);
22   }
23 
24   public int add(int x, int y)
25   {
26     return x+y;
27   }
28 
29   public static void main(String[] args)
30   {
31     ConsoleOrParameter tester=new ConsoleOrParameter();
32     tester.add();
33 
34     Scanner scanner;
35     scanner=new Scanner(System.in);
36     System.out.println("Enter the first integer.");
37     int a=scanner.nextInt();
38     int b=a*2;
39     int c=tester.add(a, b);
40     System.out.println("The result is "+c);
41   }
42 }


Download/View intro/ConsoleOrParameter.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