/* -------------------------------------------------- ユーザ定義メソッド User_teigi_method -------------------------------------------------- */ import java.io.*; class User_teigi_method { // ------------------ mainメソッド ----------------- public static void main(String[] args ) throws Exception{ int x,y,kotae=0; BufferedReader inp=new BufferedReader (new InputStreamReader(System.in)); String keybd; System.out.print("足し算をします(数を2個入れて下さい)\n"); System.out.print("x→"); keybd=inp.readLine(); x=Integer.parseInt(keybd); System.out.print("y→"); keybd=inp.readLine(); y=Integer.parseInt(keybd); kotae=kasan(x,y); // kasanメソッドの呼び出し msg(); // msgメソッドの呼び出し System.out.print("\nx+y="+kotae+"\n\n"); } // ------------------ kasanメソッド ----------------- static int kasan(int a,int b) { int c; c = a + b; return c; } // ------------------ msgメソッド ----------------- static void msg() { System.out.print("\n***定義関数を使って計算します***\n"); System.out.print("  (結果は次のとおりです)\n"); return; } }