Advertisement
MartinGeorgiev

04. Metric Converter

Mar 27th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  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, ".", "");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement