Advertisement
fiqriachmada

NumberToText

Nov 28th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     string nilai;
  8.     cout << "Input : ";
  9.     cin >> nilai;
  10.     for(int i = 0; i <= nilai.length(); i++)
  11.     {
  12.  
  13.         switch(nilai[i])
  14.         {
  15.         case '1' :
  16.             cout << "Satu ";
  17.             break;
  18.         case '2' :
  19.             cout << "Dua ";
  20.             break;
  21.         case '3' :
  22.             cout << "Tiga ";
  23.             break;
  24.         case '4' :
  25.             cout << "Empat ";
  26.             break;
  27.         case '5' :
  28.             cout << "Lima ";
  29.             break;
  30.         case '6' :
  31.             cout << "Enam ";
  32.             break;
  33.         case '7' :
  34.             cout << "Tujuh ";
  35.             break;
  36.         case '8' :
  37.             cout << "Delapan ";
  38.             break;
  39.         case '9' :
  40.             cout << "Sembilan ";
  41.             break;
  42.         case '0' :
  43.             cout << "Nol ";
  44.             break;
  45.         default:
  46.             break;
  47.         }
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement