no message
This commit is contained in:
19
Question02-Calculation/Ex01.php
Normal file
19
Question02-Calculation/Ex01.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: 20を5で割った値を出力してください
|
||||
|
||||
// 以下の1行は修正しないでください
|
||||
echo nl2br("\n");
|
||||
|
||||
// TODO: 126を13で掛けた値を出力してください
|
||||
|
||||
// 以下の1行は修正しないでください
|
||||
echo nl2br("\n");
|
||||
|
||||
// TODO: 97を6で割った時の余りを出力してください
|
||||
|
||||
|
||||
|
||||
// 補足説明
|
||||
// nl2br() は、改行コードを HTML の <br> に変換する関数
|
||||
// これを使うと、ブラウザで改行されて表示される
|
||||
10
Question02-Calculation/Ex02.php
Normal file
10
Question02-Calculation/Ex02.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$num = 10;
|
||||
print $num;
|
||||
|
||||
// TODO: 変数numの値に30を足してください
|
||||
|
||||
|
||||
// 変数numを出力する
|
||||
print $num;
|
||||
11
Question02-Calculation/Ex03.php
Normal file
11
Question02-Calculation/Ex03.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$num1 = 50;
|
||||
print $num1;
|
||||
|
||||
// TODO: 変数num2に140が入るようにしてください
|
||||
// 括弧と四則演算を使って計算してください....どうすれば140という数値になるか考えてみましょう
|
||||
|
||||
|
||||
// 以下のプログラムで140が表示されるようにしてください
|
||||
print $num2; // ※※ この行は修正しないでください
|
||||
11
Question02-Calculation/Ex04.php
Normal file
11
Question02-Calculation/Ex04.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$num = 25;
|
||||
print $num;
|
||||
|
||||
// TODO: プログラムを修正して、変数numに50が入るようにしてください
|
||||
// リテラルを使わずに、変数を使って計算してください
|
||||
|
||||
|
||||
// 以下のプログラムで50が表示されるようにしてください
|
||||
print $num; // ※※ この行は修正しないでください
|
||||
9
Question02-Calculation/Ex05.php
Normal file
9
Question02-Calculation/Ex05.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// TODO: 変数ageを定義して、数値58を代入してください
|
||||
|
||||
|
||||
// TODO: 変数nameを定義して、文字列"山田"を代入してください
|
||||
|
||||
|
||||
// TODO: 変数age、nameを連結して、「山田さんは、58歳です」と表示してください
|
||||
18
Question02-Calculation/Ex06.php
Normal file
18
Question02-Calculation/Ex06.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
$x = 10;
|
||||
$y = 50;
|
||||
|
||||
print 'x:' . $x;
|
||||
print '<br>';
|
||||
print 'y:' . $y;
|
||||
print '<br>';
|
||||
|
||||
// TODO: 変数 x, y の値をリテラルな数字を使わずに入れ替えてください
|
||||
// ※プログラムは何行書いても良いです
|
||||
|
||||
|
||||
// ここから下は修正しないでください
|
||||
print 'x:' . $x; // 「x:50」が表示される
|
||||
print '<br>';
|
||||
print 'y:' . $y; // 「y:10」が表示される
|
||||
9
Question02-Calculation/Ex07.php
Normal file
9
Question02-Calculation/Ex07.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$num = 97;
|
||||
print 'num:' . $num;
|
||||
print '<br>';
|
||||
// TODO: 変数targetを宣言して、97未満の数字を代入してください
|
||||
|
||||
|
||||
// TODO: 変数numを、変数targetで割った時の商と余りを表示してください
|
||||
7
Question02-Calculation/Ex08.php
Normal file
7
Question02-Calculation/Ex08.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$num = 20;
|
||||
$calc = 5;
|
||||
$name = "鈴木";
|
||||
|
||||
// TODO: 変数num, calc, nameを連結して、「鈴木さんは、25歳になりました」と表示してください
|
||||
15
Question02-Calculation/Ex09.php
Normal file
15
Question02-Calculation/Ex09.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$length = 9; // 底辺
|
||||
$height = 23; // 高さ
|
||||
|
||||
// TODO: 変数quadrangle に、四角形の面積を代入してください
|
||||
|
||||
|
||||
// TODO: 変数quadrangle を表示してください
|
||||
|
||||
|
||||
// TODO: 変数triangle に、三角形の面積を代入してください
|
||||
|
||||
|
||||
// TODO: 変数triangle を表示してください
|
||||
14
Question02-Calculation/Ex10.php
Normal file
14
Question02-Calculation/Ex10.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$moneyInHand = 1000; // 所持金
|
||||
$coffee = 120; // コーヒーの値段
|
||||
$snack = 200; // スナック菓子の値段
|
||||
|
||||
/* TODO:
|
||||
* ● 1本あたり120円(税別)の缶コーヒーを2本
|
||||
* ● 1袋あたり200円(税別)のスナック菓子を1袋
|
||||
*
|
||||
* 上記商品を購入した時の所持金を表示してください
|
||||
* ※ 消費税は、全商品の合計に8%が加算されます
|
||||
* ※ 日本円には小数点がありませんので、整数の値で出力してください
|
||||
*/
|
||||
151
Question02-Calculation/index.html
Normal file
151
Question02-Calculation/index.html
Normal file
@@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>PTra02スタートページ</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="../common/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
独習PHP第3章練習問題 <small>式と演算</small>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="panel-group" id="accordion">
|
||||
<!-- ================== PTra02-01 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex01.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex01
|
||||
</a> <small>四則演算</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-02 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex02.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex02
|
||||
</a> <small>変数と計算</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-03 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex03.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex03
|
||||
</a> <small>演算子の優先順位</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-04 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex04.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex04
|
||||
</a> <small>計算結果</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-05 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex05.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex05
|
||||
</a> <small>加算と連結</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================== PTra02-06 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex06.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex06
|
||||
</a> <small>スワップ</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-07 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex07.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex07
|
||||
</a> <small>剰余演算</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-08 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex08.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex08
|
||||
</a> <small>連結</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-09 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex09.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex09
|
||||
</a> <small>面積算出</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra02-10 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex10.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
|
||||
aria-hidden="true"></span>
|
||||
Ex10
|
||||
</a> <small>買い物</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery -->
|
||||
<script src="../common/js/jquery-3.2.1.min.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="../common/js/bootstrap.min"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user