From 5608326ba234e67e1305edff37c19094057c6ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B3=D0=BE=D1=80=20=D0=A1=D1=83=D0=BB=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2?= <91984484+Progragor1@users.noreply.github.com> Date: Mon, 7 Nov 2022 19:00:45 +0500 Subject: [PATCH] Create code --- code | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 code diff --git a/code b/code new file mode 100644 index 0000000..226314b --- /dev/null +++ b/code @@ -0,0 +1,211 @@ + 0) + { + $output .= " point"; + for ($i = 0; $i < strlen($fraction); $i++) + { + $output .= " " . GetSingleDigit($fraction{$i}); + } + } + return $output; +} + +function GetThreeMore($index) +{ + switch ($index) + { + case 2: + return " million"; + case 1: + return " thousand"; + case 0: + return ""; + } +} + +function GetThreeDigit($digit1, $digit2, $digit3) +{ + $buffer = ""; + + if ($digit1 == "0" && $digit2 == "0" && $digit3 == "0") + { + return ""; + } + + if ($digit1 != "0") + { + $buffer .= GetSingleDigit($digit1) . " hundred"; + if ($digit2 != "0" || $digit3 != "0") + { + $buffer .= " "; + } + } + + if ($digit2 != "0") + { + $buffer .= GetTwoDigit($digit2, $digit3); + } + else if ($digit3 != "0") + { + $buffer .= GetSingleDigit($digit3); + } + + return $buffer; +} + +function GetTwoDigit($digit1, $digit2) +{ + if ($digit2 == "0") + { + switch ($digit1) + { + case "1": + return "Ten"; + case "2": + return "Twenty"; + case "3": + return "Thirty"; + case "4": + return "Forty"; + case "5": + return "Fifty"; + case "6": + return "Sixty"; + case "7": + return "Seventy"; + case "8": + return "Eighty"; + case "9": + return "Ninety"; + } + } else if ($digit1 == "1") + { + switch ($digit2) + { + case "1": + return "Eleven"; + case "2": + return "Twelve"; + case "3": + return "Thirteen"; + case "4": + return "Fourteen"; + case "5": + return "Fifteen"; + case "6": + return "Sixteen"; + case "7": + return "Seventeen"; + case "8": + return "Eighteen"; + case "9": + return "Nineteen"; + } + } else + { + $number = GetSingleDigit($digit2); + switch ($digit1) + { + case "2": + return "Twenty $number"; + case "3": + return "Thirty $number"; + case "4": + return "Forty $number"; + case "5": + return "Fifty $number"; + case "6": + return "Sixty $number"; + case "7": + return "Seventy $number"; + case "8": + return "Eighty $number"; + case "9": + return "Ninety $number"; + } + } +} + +function GetSingleDigit($digit) +{ + switch ($digit) + { + case "0": + return "Zero"; + case "1": + return "One"; + case "2": + return "Two"; + case "3": + return "Three"; + case "4": + return "Four"; + case "5": + return "Five"; + case "6": + return "Six"; + case "7": + return "Seven"; + case "8": + return "Eight"; + case "9": + return "Nine"; + } +} + +echo(convertNumber($number)); + +?>