実行後に値を入力して処理する ● 年を入力して閏の判定をし干支を求める ● 年月日を入力して閏の判定をし干支と曜日を求める ● 年齢,性別を対話形式で入力して会費を算出する ● 入力した値が配列の何番目のものかを探索する ★ 入力した値は文字型です 適当に型変換を //------------------------何番目の干支は何?------------------------------- // 先頭に必要 import java.io.*; class search2{ public static void main(String args[]) // 例外処理 throws IOException { // 変数・配列宣言 String e[]={"申","酉","戌","亥","子","丑","寅","卯","辰","己","午","未"}; int x[]={23,56,96,21,-4,56,73,0,63,47}; // 入力バッファの定義 InputStreamReader in=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(in); // 変数 入力 System.out.print("? 番目の干支は何 0-11 を入力..."); String dn1=br.readLine(); int ww=Integer.valueOf(dn1).intValue(); if(ww>11 || ww<0) System.out.println("Wrong No"+"\n"); else System.out.println(e[ww]+"\n"); //------------- 入力した数は何番目の数?------------------ int i; String ii=""; for(i=0;i<x.length;i++){ System.out.print(x[i]+" "); } System.out.print("\n"+"入力した数は何番目? ..."); String dn2=br.readLine(); int y=Integer.valueOf(dn2).intValue(); String msg="該当なし"; for(i=0;i<x.length;i++){ if(y==x[i]) { ii=String.valueOf(i); msg="番目です"; } } System.out.println(" "+ii+msg); } } ========================================================================= あなたの会費はいくら? // 成人 未成年 長寿 // ---------------------------- // 男 4000 2000 0 // 女 3000 1500 0 // ---------------------------- import java.io.*; class kaihi2{ public static void main(String[] args) ***************** { **************************** **************************** int a=1; while(a==1){ System.out.print("How old are you ?...."); String dn1=br.readLine(); int ag=Integer.valueOf(dn1).intValue(); System.out.print("Man ⇒1 or Woman ⇒2....."); String dn2=br.readLine(); int sx=Integer.valueOf(dn2).intValue(); ************** if (**********************) price=0; else if (***********) price=1500; else if (**************) price=3000; else if (**************) price=4000; else if (sx==1 & ag<20) price=2000; System.out.println( ***********************); System.out.print("Input (1...Cont or 0...End ) ...."); String dn0=br.readLine(); a=Integer.valueOf(dn0).intValue(); } System.out.println( " ---End---"); } } ========================================================================= 閏年 干支 曜日 決定版 import java.io.*; class weekday { public static void main(String args[]) throws IOException { String w[]=******************************* String youbi[]=******************************* InputStreamReader in=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(in); // Input year System.out.print("Input year..."); ******************************* ******************************* // Input month System.out.print("Input month..."); String dn2=br.readLine(); int m=Integer.valueOf(dn2).intValue(); // Input day System.out.print("Input day..."); String dn3=br.readLine(); ******************************* //Computing int y0=y; int m0=m; int x=y%12; int r1=y%4; int r2=***************** int r3=***************** String msg="平年"; if(***********************){ msg="閏年"; } if (****************){ y=y-1; m=m+12; } int T=******************************* int t=******************************* // Output System.out.println(y0+" "+m0+" "+d+"..."+w[x]+" "+msg+" "+youbi[t]); } }