第 9 回 ことえらび レポート課題 氏名:齋藤慶太 学籍番号:c110085 語学クラス:英語2 選択コース:政策マネジメント 1 筆記問題 A ラジオボタンはHP上に選択肢を表示させひとつの項目を選択出来るようにし、選 択によって次のページを変化させたり出来る。 B チェックボックスもラジオボタンとほぼ同じ働きをもっているが複数の解答が可 能であるため利便性が良いといえる。 C 制作中に団子が食べたくなり団子を作成した。団子だけだとシンプルだったので 顔でも書くかとかいてみた。 掲載ページhttp://roy/~c110085/advertise2/ 2プログラム #htmlであることの宣言 野菜 #タイトルになる部分

野菜を3つ買います

#リンク先を掲載で連動する
  • 買うものを選択してください
  • #値段表作成

    値段表

  • きゃべつ 44円
  • とまと 55円
  • にんじん 38円
  • れたす 48円
  • なす 84円
  • たまねぎ 949円
  • ほうれんそう 387円
  • ぴーまん 487円
  • かぼちゃ 4748円
  • もやし 2円
  • #大丈夫だったら会計にすすむ #選択し直すならやり直しを選択

    #!/usr/bin/env ruby #宣言 total = 0 #合計を代入する値 $KCODE ="e" #文字コードを日本語に require 'cgi' cgi = CGI.new("html4") print("Content-type: text/html; charset=EUG-jp\n\n") ve = cgi["vegi"] #htmlとの連動の部分 ve2 = cgi["vegi2"] ve3 = cgi["vegi3"] p ve # Ruby の変数に入ったか確認 p ve2 p ve3 print("\n") print("\n") print("合計金額\n") print("\n") print("\n") if ve == "きゃべつ" #if文で合計を計算 total += 44 end if ve == "とまと" total += 55 end if ve == "にんじん" total += 38 end if ve == "れたす" total += 48 end if ve == "なす" total += 84 end if ve == "たまねぎ" total += 949 end if ve == "ほうれんそう" total += 387 end if ve == "ぴーまん" total += 487 end if ve == "かぼちゃ" total += 4748 end if ve == "もやし" total += 2 end if ve2 == "きゃべつ" total += 44 end if ve2 == "とまと" total += 55 end if ve2 == "にんじん" total += 38 end if ve2 == "れたす" total += 48 end if ve2 == "なす" total += 84 end if ve2 == "たまねぎ" total += 949 end if ve2 == "ほうれんそう" total += 387 end if ve2 == "ぴーまん" total += 487 end if ve2 == "かぼちゃ" total += 4748 end if ve2 == "もやし" total += 2 end if ve3 == "きゃべつ" total += 44 end if ve3 == "とまと" total += 55 end if ve3 == "にんじん" total += 38 end if ve3 == "れたす" total += 48 end if ve3 == "なす" total += 84 end if ve3 == "たまねぎ" total += 949 end if ve3 == "ほうれんそう" total += 387 end if ve3 == "ぴーまん" total += 487 end if ve3 == "かぼちゃ" total += 4748 end if ve3 == "もやし" total += 2 end print("

    合計金額は

    \n") printf("

    %d円になります

    ",total) print("\n") print("\n") URL html:http://roy/~c110085/advertise2/rubycgi/fork.html rb:http://roy/~c110085/advertise2/rubycgi/fork.rb 考察 プログラム問題は最初、選択肢をチェックボックスにして完成させたがチェック ボックスを利用しての足し算がなかなか分からなかったのでセレクトを使用する ことになった。理解を深めていきたいと感じる。 絵を書くことを前期でしてこなかったので作成手順が曖昧だったが今回である程 度理解できたと思う。 参考文献 西村先生ホームページ http://roy/~madoka/2011/r2/ 神田先生ホームページ http://roy/~naoya/rubyII/index.html