SHARE
TWEET

04. Metric Converter

MartinGeorgiev Mar 27th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $value = floatval(readline());
  4. $input = readline();
  5. $output = readline();
  6.  
  7. if ($input === "mm") {
  8.     $value /= 1000;
  9. } else if ($input === "cm") {
  10.     $value /= 100;
  11. }
  12.  
  13. if ($output === "mm") {
  14.     $value *= 1000;
  15. } else if ($output === "cm") {
  16.     $value *= 100;
  17. }
  18.  
  19. echo number_format($value, 3, ".", "");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top