Advertisement
agusbd

angkakehuruf

Nov 3rd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. //create by xagusart
  6.  
  7. int angka,sisa,satuan,puluhan,ratusan,ribuan,puluhribu,ratusanribu,juta;
  8.  
  9. int belas(int y)
  10. {   int x= y%10;
  11.     switch(x||y)
  12.         {
  13.         case 1:
  14.             cout<<"sebelas ";
  15.             break;
  16.          case 2:
  17.             cout<<"duabelas ";
  18.             break;
  19.          case 3:
  20.             cout<<"tigabelas ";
  21.             break;
  22.          case 4:
  23.             cout<<"empatbelas ";
  24.             break;
  25.          case 5:
  26.             cout<<"limabelas ";
  27.             break;
  28.          case 6:
  29.             cout<<"enambelas ";
  30.             break;
  31.          case 7:
  32.             cout<<"tujuhbelas ";
  33.             break;
  34.          case 8:
  35.             cout<<"delapanbelas ;";
  36.             break;
  37.         case 9:
  38.             cout<<"sembilanbelas ";
  39.             break;
  40.  
  41.         }
  42.  
  43. }
  44.  
  45. int satu(int x)
  46.  {
  47.      switch(x)
  48.      {
  49.  
  50.          case 1:
  51.             cout<<"satu";
  52.             break;
  53.          case 2:
  54.             cout<<"dua";
  55.             break;
  56.          case 3:
  57.             cout<<"tiga";
  58.             break;
  59.          case 4:
  60.             cout<<"empat";
  61.             break;
  62.          case 5:
  63.             cout<<"lima";
  64.             break;
  65.          case 6:
  66.             cout<<"enam";
  67.             break;
  68.          case 7:
  69.             cout<<"tujuh";
  70.             break;
  71.          case 8:
  72.             cout<<"delapan";
  73.             break;
  74.         case 9:
  75.             cout<<"sembilan";
  76.             break;
  77.  
  78.  
  79.      }
  80.      return 0;
  81.  
  82.  
  83.  }
  84.  
  85.  
  86. int puluh(int x)
  87. {   puluhan =0;
  88.     sisa = 0;
  89.     puluhan=x/10;
  90.     sisa=x%10;
  91.  
  92.     if(puluhan==1&&sisa>0){
  93.         return belas(sisa);
  94.     }
  95.     else
  96.     {
  97.         switch(puluhan)
  98.         {
  99.            case 1:
  100.             cout<<"sepuluh ";
  101.             break;
  102.          case 2:
  103.             cout<<"dua puluh ";
  104.             break;
  105.          case 3:
  106.             cout<<"tiga puluh ";
  107.             break;
  108.          case 4:
  109.             cout<<"empat puluh ";
  110.             break;
  111.          case 5:
  112.             cout<<"lima puluh ";
  113.             break;
  114.          case 6:
  115.             cout<<"enam puluh ";
  116.             break;
  117.          case 7:
  118.             cout<<"tujuh puluh ";
  119.             break;
  120.          case 8:
  121.             cout<<"delapan puluh ";
  122.             break;
  123.         case 9:
  124.             cout<<"sembilan puluh ";
  125.             break;
  126.         }
  127.  
  128.         return satu(sisa);
  129.  
  130.  
  131.     }
  132. }
  133.  
  134. int ratus(int x)
  135.  
  136. {   sisa = 0;
  137.     ratusan = 0;
  138.     ratusan= x/100;
  139.     sisa= x%100;
  140.      switch(ratusan)
  141.      {
  142.  
  143.          case 1:
  144.             cout<<"seratus ";
  145.             break;
  146.          case 2:
  147.             cout<<"duaratus ";
  148.             break;
  149.          case 3:
  150.             cout<<"tigaratus ";
  151.             break;
  152.          case 4:
  153.             cout<<"empatratus ";
  154.             break;
  155.          case 5:
  156.             cout<<"limaratus ";
  157.             break;
  158.          case 6:
  159.             cout<<"enamratus ";
  160.             break;
  161.          case 7:
  162.             cout<<"tujuh ratus ";
  163.             break;
  164.          case 8:
  165.             cout<<"delapan ratus ";
  166.             break;
  167.         case 9:
  168.             cout<<"sembilan ratus ";
  169.             break;
  170.  
  171.  
  172.      }
  173.      return puluh(sisa);
  174.  
  175.  
  176. }
  177. int belasribu(int x)
  178. {
  179.     switch(x)
  180.         {
  181.         case 11:
  182.             cout<<"sebelas ribu ";
  183.             break;
  184.          case 22:
  185.             cout<<"duabelas ribu ";
  186.             break;
  187.          case 33:
  188.             cout<<"tigabelas ribu ";
  189.             break;
  190.          case 14:
  191.             cout<<"empatbelas ribu ";
  192.             break;
  193.          case 15:
  194.             cout<<"limabelas ribu ";
  195.             break;
  196.          case 16:
  197.             cout<<"enambelas ribu ";
  198.             break;
  199.          case 17:
  200.             cout<<"tujuhbelas ribu";
  201.             break;
  202.          case 18:
  203.             cout<<"delapanbelas ribu ;";
  204.             break;
  205.         case 19:
  206.             cout<<"sembilanbelas ribu ";
  207.             break;
  208.  
  209.         }
  210.         return ratus(sisa);
  211.  
  212. }
  213.  
  214. int ribu(int x)
  215. {
  216.     if(x<1000)
  217.         return ratus(x);
  218.     ribuan = x/1000;
  219.     int kkl = x%1000;
  220.  
  221.     if(ribuan>10&&ribuan<20)
  222.     {
  223.        belas(ribuan);
  224.         cout<<" ribu ";
  225.         return ratus(sisa);
  226.     }
  227.     else
  228.     {
  229.  
  230.  
  231.         int sisak=x/1000;
  232.  
  233.         ratus(sisak);
  234.         cout<<" ribu ";
  235.  
  236.      }
  237.      return ratus(kkl);
  238.  
  239. }
  240.  
  241. int jutaan(int x)
  242. {
  243.  
  244.     if(x<1000000)
  245.         return ribu(x);
  246.     juta = x/1000000;
  247.     int mm = x%1000000;
  248.  
  249.     if(juta>10&&juta<20)
  250.     {
  251.        belas(ribuan);
  252.         cout<<" juta ";
  253.         return ratus(sisa);
  254.     }
  255.     else
  256.     {
  257.  
  258.  
  259.         int sisak=x/1000000;
  260.  
  261.         ratus(sisak);
  262.         cout<<" juta ";
  263.  
  264.      }
  265.      return ribu(mm);
  266.  
  267.  
  268. }
  269.  
  270.  
  271. int main()
  272. {
  273.     cout<<"input angka : ";cin>>angka;
  274.     if(angka<0)
  275.     {
  276.  
  277.         cout<<"negativ ";
  278.         int km = abs(angka);
  279.         jutaan(km);
  280.     }
  281.  
  282.  
  283.     jutaan(angka);
  284.  
  285.  
  286. return 0;
  287.  
  288.  
  289.  
  290.  
  291. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement