LoginSignup
0
1

More than 3 years have passed since last update.

入力値は全体の何パーセント

Last updated at Posted at 2019-07-14

入力した数値から全体の何パーセントなのかを求めるソース

ソースコード

<?php
// Your code here!
//全体値を入力
$Population = 1000;
//求めたい人口を入力(0だと未入力)
$Cut = "0";

//割合計算用の数値に変換
$wariai = $Cut * 0.1;

//割合を求める
if(!$Cut){
    echo "入力値が入っていません";
} else {
    $kekka = $wariai / $Population * 100;
    echo "入力した値は、全体値の$kekka";
    echo "%です";
}

?>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1