Files
php-question-answer/Question02-Calculation/Ex10.php
2026-10-09 12:33:29 +09:00

20 lines
687 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$moneyInHand = 1000; // 所持金
$coffee = 120; // コーヒーの値段
$snack = 200; // スナック菓子の値段
/*
* ● 1本あたり120円(税別)の缶コーヒーを2本
* ● 1袋あたり200円(税別)のスナック菓子を1袋
*
* 上記商品を購入した時の所持金を表示してください
* ※ 消費税は、全商品の合計に8%が加算されます
* ※ 日本円には小数点がありませんので、整数の値で出力してください
*/
$total = ($coffee * 2) + $snack;
$tax = $total * 0.08;
$taxTruncation = floor($tax);
$moneyInHand = $moneyInHand - ($total + $taxTruncation);
echo '所持金' . $moneyInHand;