<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/bz521717/">
    <title>bz521717 @ ウィキ</title>
    <link>http://w.atwiki.jp/bz521717/</link>
    <atom:link href="https://w.atwiki.jp/bz521717/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>bz521717 @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2009-12-11T17:08:00+09:00</dc:date>
    <utime>1260518880</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/37.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/39.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/36.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/38.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/2.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/35.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/27.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/34.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/33.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/bz521717/pages/3.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/37.html">
    <title>チャレンジ1</title>
    <link>https://w.atwiki.jp/bz521717/pages/37.html</link>
    <description>
      ＊補足説明

以前のプログラム（Error2.java）ではSumupStudent→Error2
で作っていましたがSumupStudentのままでも問題なく動くので今回は変更しないで作成しました。

＊注意
このプログラムをコンパイルするときには
javac Error2.java
プログラムを動かす時には
java SumupStudent
となるので注意してください。



//課題2-2 エラー箇所を見つけて修正しよう！

class Student {
	//インスタンス変数の宣言
	private String name;	//名前
	private int[] result = new int[3];   //テストの点数格納配列（数学、化学、物理）
	private float total=0;	//合計点
	private float ave=0;	//平均点
	//コンストラクタ(Java絵本P74)
	public Student(String who, int math, int chemistry, int physics){
		//インスタンス変数への値の代入
		name = who;
		result[0] = math;
		result[1] = chemistry;
		result[2] = physics;
	}

	//学生の名前の取得
	public String getName(){
		return name;
	}

	//各科目の点数の取得
	public int getResult(int num){
		return result[num];
	}

	//合計点の取得
	public float getTotal(){
		//合計点の初期化
		total = 0;
		for(int i=0; i&lt;result.length; i++){
			 total = total + result[i];
		}
		return total;
	}
	//平均点の取得
	public float getAve(){
		ave = 0;
		if(total!=0){
			ave=total/result.length;
		}
		return ave;
	}
}


class SumupStudent{
	public static void main(String args[]){
		//Studentクラスのインスタンス生成
		Student sato = new Student(&quot;佐藤&quot;,77,65,80);  //佐藤オブジェクト
		Student suzuki = new Student(&quot;鈴木&quot;,88,59,90);//鈴木オブジェクト
		Student tanaka = new Student(&quot;田中&quot;,64,85,54);//田中オブジェクト

		//学生テストデータの出力
		//佐藤さんのデータ;
		System.out.println(sato.getName()+ &quot;さんのテスト結果&quot;);
		System.out.print(&quot;数学:&quot; + sato.getResult(0) + &quot;点 &quot;);
		System.out.print(&quot;化学:&quot; + sato.getResult(1) + &quot;点 &quot;);
		System.out.println(&quot;物理:&quot; + sato.getResult(2) + &quot;点 &quot;);
		System.out.println(&quot;合計:&quot; + sato.getTotal()+ &quot;点 &quot;);
		System.out.println(&quot;平均:&quot; + sato.getAve()+ &quot;点 &quot;);
		System.out.println(tanaka.getName()+ &quot;さんのテスト結果&quot;);
		System.out.print(&quot;数学:&quot; + tanaka.getResult(0) + &quot;点 &quot;);
		System.out.print(&quot;化学:&quot; + tanaka.getResult(1) + &quot;点 &quot;);
		System.out.println(&quot;物理:&quot; + tanaka.getResult(2) + &quot;点 &quot;);
		System.out.println(&quot;合計:&quot; + tanaka.getTotal()+ &quot;点 &quot;);
		System.out.println(&quot;平均:&quot; + tanaka.getAve()+ &quot;点 &quot;);
	}

}    </description>
    <dc:date>2009-12-11T17:08:00+09:00</dc:date>
    <utime>1260518880</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/39.html">
    <title>チャレンジ3</title>
    <link>https://w.atwiki.jp/bz521717/pages/39.html</link>
    <description>
      class Square{
     // インスタンス変数の定義
     private int height; //縦の辺の長さ
     private int width; //横の辺の長さ
     private int s;//面積

     // 縦の辺の長さと横の辺の長さを引数にもつコンストラクタの定義
     //****** ここにコンストラクタの定義を追加します *********
     Square(int h,int w){
    	 height=h;//縦の辺の長さセット
    	 width=w;//横の辺の長さセット
     }

     // getAreaメソッドの定義 戻り値は四角形の面積とする
     //****** ここにgetAreaメソッドの定義を追加します*********
     void   getArea(){

    	 s=height*width;
     }
   //辺の縦と横の長さの表示,面積の表示
     void getData(){
    	 System.out.print(&quot;縦：&quot;+ height+&quot;cm\t&quot;);
    	 System.out.println(&quot;横：&quot;+ width+&quot;cm&quot;);
    	 System.out.println(&quot;四角形の面積は&quot;+s+&quot;平方センチメートルです。&quot;);
     }
}

class Exercises {
     public static void main(String[] args) {

    	 try{
    	 if(args.length==2){ //コマンドライン引数の個数が2つのとき

        	  int i,j;


               //****** 以下のコメントに対応するコードを追加し処理を完成させます *******
               //Squareクラス型オブジェクトの作成
               //コマンドライン引数から入力された数値を縦、横の辺の長さとして使用する
               //SquareクラスのgetAreaメソッドを利用して四角形の面積を取得し表示する
        	  i=Integer.parseInt(args[0]);
        	  j=Integer.parseInt(args[1]);
        	  Square sq=new Square(i,j);
        	  sq.getArea();
        	  sq.getData();
          } else { //コマンドライン引数の個数が2つ以外のとき

               //****** 以下のコメントに対応するコードを追加し処理を完成させます *******
               //「コマンドライン引数には、2つの数値を入力してください。」を表示する
        	  System.out.println(&quot;コマンドライン引数には、2つの数値を入力してください。&quot;);

          }
    	 }
    	 catch(NumberFormatException e){
    			System.out.println(&quot;arg[0] 、arg[1]には半角数値を入力してください。&quot;);
    			}
     }
}    </description>
    <dc:date>2009-12-11T16:56:10+09:00</dc:date>
    <utime>1260518170</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/36.html">
    <title>チャレンジ</title>
    <link>https://w.atwiki.jp/bz521717/pages/36.html</link>
    <description>
      -[[チャレンジ1]]
-[[チャレンジ2]]
-[[チャレンジ3]]    </description>
    <dc:date>2009-12-11T16:55:59+09:00</dc:date>
    <utime>1260518159</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/38.html">
    <title>チャレンジ2</title>
    <link>https://w.atwiki.jp/bz521717/pages/38.html</link>
    <description>
      class Square{
     // インスタンス変数の定義
     private int height; //縦の辺の長さ
     private int width; //横の辺の長さ
     private int s;//面積

     // 縦の辺の長さと横の辺の長さを引数にもつコンストラクタの定義
     //****** ここにコンストラクタの定義を追加します *********
     Square(int h,int w){
    	 height=h;//縦の辺の長さセット
    	 width=w;//横の辺の長さセット
     }

     // getAreaメソッドの定義 戻り値は四角形の面積とする
     //****** ここにgetAreaメソッドの定義を追加します*********
     void   getArea(){

    	 s=height*width;
     }
   //辺の縦と横の長さの表示,面積の表示
     void getData(){
    	 System.out.print(&quot;縦：&quot;+ height+&quot;cm\t&quot;);
    	 System.out.println(&quot;横：&quot;+ width+&quot;cm&quot;);
    	 System.out.println(&quot;四角形の面積は&quot;+s+&quot;平方センチメートルです。&quot;);
     }
}

class Exercises {
     public static void main(String[] args) {
          if(args.length==2){ //コマンドライン引数の個数が2つのとき

        	  int i,j;


               //****** 以下のコメントに対応するコードを追加し処理を完成させます *******
               //Squareクラス型オブジェクトの作成
               //コマンドライン引数から入力された数値を縦、横の辺の長さとして使用する
               //SquareクラスのgetAreaメソッドを利用して四角形の面積を取得し表示する
        	  i=Integer.parseInt(args[0]);
        	  j=Integer.parseInt(args[1]);
        	  Square sq=new Square(i,j);
        	  sq.getArea();
        	  sq.getData();
          } else { //コマンドライン引数の個数が2つ以外のとき

               //****** 以下のコメントに対応するコードを追加し処理を完成させます *******
               //「コマンドライン引数には、2つの数値を入力してください。」を表示する
        	  System.out.println(&quot;コマンドライン引数には、2つの数値を入力してください。&quot;);

          }
     }
}    </description>
    <dc:date>2009-12-11T16:47:42+09:00</dc:date>
    <utime>1260517662</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/2.html">
    <title>メニュー</title>
    <link>https://w.atwiki.jp/bz521717/pages/2.html</link>
    <description>
      **メニュー
-[[トップページ]]
-[[プラグイン紹介&gt;プラグイン]]
-[[まとめサイト作成支援ツール]]
-[[☆実習課題☆]]
-[[課題]]
-[[チャレンジ]]
-[[質問掲示板]]

----

**リンク
-[[@wiki&gt;&gt;http://atwiki.jp]]
-[[@wikiご利用ガイド&gt;&gt;http://atwiki.jp/guide/]]

**他のサービス
-[[無料ホームページ作成&gt;&gt;http://atpages.jp]]
-[[無料ブログ作成&gt;&gt;http://atword.jp]]
-[[2ch型掲示板レンタル&gt;&gt;http://atchs.jp]]
-[[無料掲示板レンタル&gt;&gt;http://atbbs.jp]]
-[[お絵かきレンタル&gt;&gt;http://atpaint.jp/]]
-[[無料ソーシャルプロフ&gt;&gt;http://sns.atfb.jp/]]

// リンクを張るには &quot;[&quot; 2つで文字列を括ります。
// &quot;&gt;&quot; の左側に文字、右側にURLを記述するとリンクになります


//**更新履歴
//#recent(20)

&amp;link_editmenu(text=ここを編集)    </description>
    <dc:date>2009-12-11T15:33:38+09:00</dc:date>
    <utime>1260513218</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/35.html">
    <title>☆実習課題☆ 6-1</title>
    <link>https://w.atwiki.jp/bz521717/pages/35.html</link>
    <description>
      import java.io.*;

class FileCopy{
	public static void main(String args[]){
		int b;

		if (args.length != 2) {
			System.err.println(&quot;読み込みファイルと書き込みファイルをそれぞれ入力してください&quot;);
		System.exit(-1);
		}
		try {
			// バイト・ストリームの獲得（ファイルのオープン）
			FileOutputStream fos = new FileOutputStream(args[1]);//書き込みファイル　コピー先ファイル
			FileInputStream fis = new FileInputStream(args[0]);//読み込みファイル　コピー元ファイル
			while ((b = fis.read()) != -1) {
				System.out.println(b); // 読み込んだデータの表示
				fos.write(b);//読み込んだデータを書き込む
			}
			System.out.println(&quot;- - 読み込み完了- -&quot;);
			fis.close(); // ストリームのクローズ（ファイルのクローズ）
			fos.close();//ストーリムのクローズ
		}
		catch (FileNotFoundException e){
			System.err.println(&quot;ファイルが見つかりませんでした&quot;);
		}
		catch (IOException e) {
			System.err.println(&quot;ファイルのオープン・クローズまたは書き込みに失敗しました&quot;);
			e.printStackTrace();
		}
	}
}    </description>
    <dc:date>2009-11-01T00:26:36+09:00</dc:date>
    <utime>1257002796</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/27.html">
    <title>☆実習課題☆</title>
    <link>https://w.atwiki.jp/bz521717/pages/27.html</link>
    <description>
      -[[☆実習課題☆ 3-1]]
-[[☆実習課題☆ 3-2]]
-[[☆実習課題☆ 3-3]]
-[[☆実習課題☆ 4-1]]
-[[☆実習課題☆ 5-1]]
-[[☆実習課題☆ 6-1]]    </description>
    <dc:date>2009-11-01T00:25:35+09:00</dc:date>
    <utime>1257002735</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/34.html">
    <title>☆実習課題☆ 5-1</title>
    <link>https://w.atwiki.jp/bz521717/pages/34.html</link>
    <description>
      class MyRunnable implements Runnable{
	String name;
	// コンストラクタ
	public MyRunnable(String s){
	name = s;
	}
	// オーバーライドされたrunメソッド
	public void run(){
		while(true){
			System.out.println(name);
		}
	}
}

class MyRunnableApp{
	public static void main(String args[]){
	// スレッドの作成
	MyRunnable r1 = new MyRunnable(&quot;Runnable1&quot;);
	Thread t1 = new Thread(r1);
	MyRunnable r2 = new MyRunnable(&quot;Runnable2&quot;);
	Thread t2 = new Thread(r2);
	MyRunnable r3 = new MyRunnable(&quot;Runnable3&quot;);
	Thread t3 = new Thread(r3);
	// スレッドの実行開始
	t1.start();
	t2.start();
	t3.start();
	}
}    </description>
    <dc:date>2009-10-30T23:16:14+09:00</dc:date>
    <utime>1256912174</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/33.html">
    <title>☆実習課題☆ 4-1</title>
    <link>https://w.atwiki.jp/bz521717/pages/33.html</link>
    <description>
      import jp.co.jip.st.common.*;//パッケージのインポート

class CheckDaysTest{
	int Seireki,Tsuki,Hinichi;
	public static void main(String args[]) {
	try{
		CheckDays cd=new CheckDays(args[0],args[1]);
		cd.setData();
		cd.Data();
		cd.getData();
		System.out.println();
		System.out.println(&quot;例外発生時にはこの行は出力されません&quot;);
	}
	catch(ArrayIndexOutOfBoundsException e){
		System.out.println(&quot;引数は&lt;西暦&gt;と&lt;年&gt;の2 つです&quot;);
		}
		catch(NumberFormatException e){
		System.out.println(&quot;数値に変換できない型です&quot;);
		}
		catch(Exception e){
		System.out.println(&quot;例外：すべての例外をキャッチします&quot;);
		System.out.println(&quot;例外：&quot; + e.getMessage());
           //UserException2をExceptionに継承しているためe.getMessage()で予期せぬエラーが発生しましたが表示される
		}
		finally{
		System.out.println(&quot;この行は例外に関わらず出力されます&quot;);
		}
	}
}

package jp.co.jip.st.common;//パッケージ化

public class CheckDays{

	int Seireki,Tsuki,Hinichi;
	String seireki,tsuki;
	 public CheckDays(String a,String b){
		 seireki=a;
		 tsuki=b;
	 }
		public void setData()throws UserException2{
			Seireki=Integer.parseInt(seireki);
			Tsuki=Integer.parseInt(tsuki);
			if(Tsuki&gt;12){
				throw new UserException2(Seireki,Tsuki);
			}
			else if(Tsuki&lt;=0){
				throw new UserException2(Seireki,Tsuki);
			}
			else if(Seireki&lt;0){
				throw new UserException2(Seireki,Tsuki);
			}
		}

		public void Data(){//月ごとの日数を調べるメソッド
		switch(Tsuki){
			case 1:
				Hinichi=31;
				break;
			case 2:
				if(Seireki%4==0){
					Hinichi=29;
				}
				if(Seireki%100==0){
					Hinichi=28;
				}
				if(Seireki%400==0){
					Hinichi=29;
				}
				else{
					Hinichi=28;
				}
				break;
			case 3:
				Hinichi=31;
				break;
			case 4:
				Hinichi=30;
				break;
			case 5:
				Hinichi=31;
				break;
			case 6:
				Hinichi=30;
				break;
			case 7:
				Hinichi=31;
				break;
			case 8:
				Hinichi=31;
				break;
			case 9:
				Hinichi=30;
				break;
			case 10:
				Hinichi=31;
				break;
			case 11:
				Hinichi=30;
				break;
			case 12:
				Hinichi=31;
				break;
			default:
			}
		}
	public void getData(){
		System.out.print(Seireki+&quot;年&quot;+Tsuki+&quot;月は、&quot;+Hinichi+&quot;日です。&quot;);
	}
}


package jp.co.jip.st.common;//パッケージ化

public class UserException2 extends Exception{
	
	int userErr;
	int userInt;

	public UserException2 (int err, int eInt){
		userErr = err;//西暦
		userInt = eInt;//月
	}
	
	public String getMessage(){
		if(userInt&gt;12){
			System.out.println(&quot;&lt;月&gt; は1 から12 の数値を入力してください&quot;);
		}
		if(userInt&lt;=0){
			System.out.println(&quot;&lt;月&gt; は1 から12 の数値を入力してください&quot;);
		}
		if(userErr&lt;0){
			System.out.println(&quot;&lt;西暦&gt; は0 以上の数値を入力してください&quot;);
		}
		return &quot;予期せぬエラーが発生しました&quot;;
	}
}    </description>
    <dc:date>2009-10-28T15:57:39+09:00</dc:date>
    <utime>1256713059</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/bz521717/pages/3.html">
    <title>右メニュー</title>
    <link>https://w.atwiki.jp/bz521717/pages/3.html</link>
    <description>
      **更新履歴
#recent(20)


&amp;link_editmenu2(text=ここを編集)    </description>
    <dc:date>2009-10-28T15:27:20+09:00</dc:date>
    <utime>1256711240</utime>
  </item>
  </rdf:RDF>
