#include <iostream>
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
void first (int n) {
switch (n) {
case 1: cout<<"Satu "; break;
case 2: cout<<"Dua "; break;
case 3: cout<<"Tiga "; break;
case 4: cout<<"Empat "; break;
case 5: cout<<"Lima "; break;
case 6: cout<<"Enam "; break;
case 7: cout<<"Tujuh "; break;
case 8: cout<<"Delapan "; break;
case 9: cout<<"Sembilan "; break;
case 10: cout<<"Sepuluh "; break;
case 11: cout<<"Sebelas "; break;
default: break;
}
}
void second (int n) {
int bul, sisa;
bul = n / 10;
sisa = n % 10;
if (bul == 0)
first (sisa);
else if (bul == 1) {
if (sisa <= 1)
first (n);
else {
first (sisa);
cout<<"Belas ";
}
}
else {
first (bul);
cout<<"Puluh ";
first (sisa);
}
}
void third (int n) {
int bul, sisa;
bul = n / 100;
sisa = n % 100;
if (bul == 0)
second (sisa);
else if (bul == 1) {
if (sisa == 0)
cout<<"Seratus ";
else {
cout<<"Seratus ";
second (sisa);
}
}
else {
first (bul);
cout<<"Ratus ";
second (sisa);
}
}
void fourth (int n) {
int bul, sisa;
bul = n / 1000;
sisa = n % 1000;
if (bul == 0)
third (sisa);
else if (bul == 1) {
if (sisa == 0)
cout<<"Seribu ";
else {
cout<<"Seribu ";
third (sisa);
}
}
else {
third (bul);
cout<<"Ribu ";
third (sisa);
}
}
void fifth (int n) {
int bul, sisa;
bul = n / 1000000;
sisa = n % 1000000;
if (bul == 0)
fourth (sisa);
else if (bul == 1) {
if (sisa == 0)
cout<<"Satu Juta ";
else {
cout<<"Satu juta ";
fourth (sisa);
}
}
else {
third (bul);
cout<<"Juta ";
fourth (sisa);
}
}
int main(int argc, char** argv) {
int n = 1;
while (n == 1) {
int num1;
do {
cout<< "";
cin>>num1;
} while (num1<1);
fifth (num1);
cout<<"\n";
}
return 0;
}
Tidak ada komentar:
Posting Komentar