専門学校46日目(情報工学)6月17日(月)

1時限~3時限
HTML基礎 スラスラわかるHTML&CSSの基本 第2版

本日は中間試験でした。詳しくは載せられませんが、問題2は自己紹介を自分で作るという内容でしたので、書いたものを載せます。1問目は2問目をややこしくしたような内容です。

<!-- 自己紹介を作成すること-->
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>自己紹介</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1 id="top">自己紹介</h1>
<p>ページ作成者のことを以下の順で紹介していくよ。</p>
<ul>
 <li><a href="#name">名前</a>
 </li><li><a href="#class">クラス</a>
 </li><li><a href="#favorite">好きなこと</a></li>
</ul>
</header>
<main>
<img src="image/videogame_boy.png" alt="ゲームで遊ぶ男の子">
<h2 id="name">名前</h2>
<p>名前は飯田延千代(イイダ ノブチヨ)です。</p>
<h2 id="class">クラス</h2>
<p>情報工学科ソフトウェア開発コースのSAクラスに所属しています。</p>
<h2 id="favorite">好きなこと</h2>
<p>おいしいものを食べることやゲーム、数学が好きです。ハンバーガーみたいなジャンクフードはめったに食べないけど大好きです。好きなゲームはスマホでプレイできるソーシャルゲームですが、幻影戦争というゲームが好きです。学校に通いながらだとなかなか時間が取れなくてゲームをする時間が減っていますが、マイペースに続けています。数学はどんなことを学んでいるかというと、最近は行列の扱いや性質などの基礎的なことを復習しています。ある行列の固有値(重複を含めて)の積は行列式の値に等しいとか、固有値の和はtr(トレース)に等しいとかそんなことを学んでいます。<p/>
<img src="image/hamburger.png" alt="ハンバーガー">
<img src="image/002.jpg" width="179" height="141" alt="幻影戦争">
<img src="image/math.jpg" width="179" height="141" alt="数学">
</main>
<footer>
<p><a href="#top">トップページに戻る</a></p>
</footer>
</body>
</html>

CSSは以下の通り

h1 {
    color: #ffffff;
    padding-left: 30px;
    background: #808080;
}

header ul {
    border: solid 4px #00ff00;
    color: #000080;
    padding-top: 10px;
    padding-bottom: 10px;
}

body {
    background: #808000;
}

h2 {
    color: #ffffff;
    border-left: solid 20px #808080;
    padding-left: 10px;
}

4時限~6時限
Java基礎 スッキリわかるJava入門 第4版

中間試験の結果が返されました。
p.100- プログラムの基本構造
順次、分岐、繰り返し
これはどのプログラミング言語も同じなので、しっかり学んでください。そうすればC言語でもPythonでも書けるようになります。
期末試験にはif文や繰り返し文(while文、for文)を出題します。


pdf資料で繰り返し構文の解説を受けました。解説をもとにコードを書きました。

public class Main { 
    public static void main(String[] args) { 
        int cnt = 0;  
        while (cnt<5) { 
        System.out.println("現在のcntは" + cnt + "です。"); 
        System.out.println("こんにちは。"); 
        cnt++; 
        }
    }
}

演習問題

public class Main { 
    public static void main(String[] args) {  
        int cnt = 5; 
        while (cnt>0) { 
            System.out.println("cnt=" + cnt); 
            cnt--; 
        } 
    }
}

演習問題その2

public class Main { 
    public static void main(String[] args) { 
        int hantei = 1; 
        while (hantei == 1) { 
            System.out.println("お腹すいたぁ"); 
            System.out.println("数字を入力してください。"); 
            hantei = new java.util.Scanner(System.in).nextInt(); 
        } 
    }
}

②
public class Main { 
    public static void main(String[] args) { 
        int cnt = 1; //カウント用変数 
        while (cnt<11) { 
            System.out.println("cnt=" + cnt); 
            cnt++; 
        } 
    }
}

③
public class Main { 
    public static void main(String[] args) { 
        int cnt = 1; //カウント用変数 
        while (cnt<11) { 
            System.out.println("cnt=" + cnt); 
            cnt += 2; 
        } 
    }
}

④
public class Main { 
    public static void main(String[] args) { 
        int cnt = 2; //カウント用変数 
        while (cnt<11) { 
            System.out.println("cnt=" + cnt); 
            cnt += 2; 
        } 
    }
}

⑤
public class Main { 
    public static void main(String[] args) { 
        int cnt = 1; //カウント用変数 
        int sum = 0; //合計用変数 
        System.out.println("1から10までの合計を求めます。"); 
        while (cnt<11) { 
            sum += cnt; 
            cnt++; 
        } 
        System.out.println("合計は" + sum + "です。"); 
    }
}

⑥
public class Main { 
    public static void main(String[] args) { 
        int kingaku = 0; //貯金していく数 
        int total = 0; //合計用変数 
        while (total<100) { 
            System.out.println("貯金する額を入力してください。"); 
            kingaku = new java.util.Scanner(System.in).nextInt(); 
            System.out.println(kingaku + "万円貯金しました。"); 
            total += kingaku; 
        } 
        System.out.println("貯金額=" + total + "万円"); 
        System.out.println("やったぁ!100万円貯金達成!"); 
    }
}

⑦
public class Main { 
    public static void main(String[] args) { 
        int jikan = 9; 
        while (jikan < 17) { 
            System.out.println("今、" + jikan + "時です。"); 
            if (jikan <= 12) { 
                System.out.println("(お昼、まだかなぁ)"); 
            } else { 
                System.out.println("(早く帰りたいなぁ)"); 
            } 
            jikan++; 
        } 
        System.out.println(jikan + "時になりました。"); 
        System.out.println("(やったぁ!お仕事終わり!)"); 
    }
}

⑧
public class Main { 
    public static void main(String[] args) { 
        int cnt = 10; //カウント用変数 
        System.out.println("カウントダウンを始めます。"); 
        while (cnt > -1) { 
            System.out.println("カウント" + cnt); 
            cnt--; 
        } 
    }
}

⑨
public class Main { 
    public static void main(String[] args) { 
        int tensuu = 0; //キーボード入力を入れる変数 
        int total = 0; //合計点を入れる変数 
        double heikin = 0; //平均点を入れる変数 
        int cnt = 0; //カウント用変数 
        System.out.println("5科目のテストの点数を入力してください。"); 
        while (cnt < 5) { 
            System.out.print((cnt + 1) + "科目目"); 
            tensuu = new java.util.Scanner(System.in).nextInt(); 
            total += tensuu; 
            cnt++; 
        } 
        heikin = total / 5.0; 
        System.out.println("平均点は" + heikin + "点です。"); 
    }
}

後判定の処理だと継続条件の判定をループの中の処理は必ず1回は行う。
実務では前判定のプログラムを書くのが一般的だが、たまに使うかもしれない。
do~while文で書く。

public class Main { 
    public static void main(String[] args) {  
        int cnt = 10; //カウント用変数  
        do { 
            System.out.println("cnt = " + cnt); 
            cnt++; 
        } while (cnt < 10); 
    }
}

演習問題

public class Main { 
    public static void main(String[] args) {  
        int cnt = 1, total = 0; 
        System.out.println("1から9までの合計値を表示します。"); 
        do { 
            total += cnt; 
            cnt++; 
        } while (cnt < 10); 
        System.out.println("合計は" + total + "です。"); 
    }
}

教科書p.123-
while文は前判定なので、条件式が満たなければ処理されない。
do~while文は後判定なので必ず1回は実行される。
for文による繰り返し
for文のほうが使うケースが多い。決まった数を繰り返したいか回数で制限を設ける場合は、for文を使うとよい。
身長が何センチの間は、とか温度が何度の間は、という場合は、while文を使うとよい。

public class Main { 
    public static void main(String[] args) { 
        for (int i = 0; i < 10; i++) { 
            System.out.println("現在のiは" + i); 
            System.out.println("こんにちは"); 
        } 
    }
}

public class Main { 
    public static void main(String[] args) { 
        for (int i = 10; i > 0; i--) { 
            System.out.println("現在のiは" + i); 
        } 
    }
}

7限目
IT法規 知的財産権管理技能検定3級 公式テキスト改訂14版

本日の授業は特許情報プラットフォーム|J-PlatPat [JPP] (inpit.go.jp)から特許を探してそれを用紙に書いて提出するという内容でした。申請中のものを検索に多くヒットするのできちんと特許が登録されているものを探すのはなかなか難しかったです。

この記事が気に入ったらサポートをしてみませんか?