{"id":2376,"date":"2020-10-02T09:04:49","date_gmt":"2020-10-02T02:04:49","guid":{"rendered":"https:\/\/luckytruedev.com\/learning\/?p=2376"},"modified":"2020-10-02T09:04:51","modified_gmt":"2020-10-02T02:04:51","slug":"contoh-program-konversi-bilangan-ke-penyebutan-java","status":"publish","type":"post","link":"https:\/\/luckytruedev.com\/learning\/contoh-program-konversi-bilangan-ke-penyebutan-java\/","title":{"rendered":"Contoh Program Konversi Bilangan ke Penyebutan Java"},"content":{"rendered":"\n<pre class=\"wp-block-syntaxhighlighter-code\">import java.util.Scanner;\n\npublic class KonversiBilangan{\n    String[] angka={\"\",\"Satu\",\"Dua\",\"Tiga\",\"Empat\",\"Lima\",\"Enam\",\"Tujuh\",\"Delapan\",\"Sembilan\",\"Sepuluh\",\"Sebelas\"};\n    \n    public String terbilang(long  x){\n        int y;\n        String bilang=\"\";\n        String[] satuan={\"\",\" Ribu \",\" Juta \",\" Milyar \",\" Trilyun \",\" Quadrilyun \",\" Quintilyun \"};\n        if(x > Math.pow(10, 20)) return \"Bilangan terlalu besar\";\n        for(int i=6;i>0;i--){\n            y =  (int) (x\/Math.pow(10, i*3));\n            if(y > 0){\n                if(y==1 &amp;&amp; i==1) bilang += \" Seribu \"; else bilang += sebut(y) + satuan[i];\n            } x %= Math.pow(10, i*3);\n        }\n        bilang+=sebut((int)x);\n        return bilang;\n    }\n\n    public String sebut(int x){\n        String bilang=\"\";\n        int y = x \/ 100;\n        if(y > 0){\n            bilang = angka[y]+\" Ratus \";\n            if(y == 1)bilang=\"Seratus \";\n            x%=100;\n        }\n        if(x&lt;12)bilang += angka[x];\n        else{\n            y=x\/10;\n            x%=10;\n            if(y==1)\n                bilang +=angka[x] + \" Belas\";\n            else\n                bilang += angka[y]+ \" Puluh \"+ angka[x];\n        }\n        return bilang;\n    }\n\n    public static void main(String[] coedotz) {\n        Scanner input = new Scanner(System.in);\n        System.out.print(\"Masukan Bilangan yang akan disebut: \");\n        System.out.println(new KonversiBilangan().terbilang(input.nextLong()));\n        input.close();\n    }\n}<\/pre>\n<div id=\"lucky-2232364731\" class=\"lucky-after-content lucky-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[344],"tags":[],"class_list":["post-2376","post","type-post","status-publish","format-standard","hentry","category-java"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/2376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/comments?post=2376"}],"version-history":[{"count":1,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/2376\/revisions"}],"predecessor-version":[{"id":2377,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/2376\/revisions\/2377"}],"wp:attachment":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/media?parent=2376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/categories?post=2376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/tags?post=2376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}