WHAT'S NEW?
Loading...

C++ Nominal Reader Program Program

//Program Pembaca Nominal Menggunakan C++

#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
void bilangan(int prm,int d)
     {
        switch(prm)
                    {
                        case 49:if(d==0||d==3|| d==6 || d==9|| d==12){cout<<"Satu ";}
                                if(d==1||d==2||d==4||d==5||d==7||d==8|| d==13||14){cout<<"Se";}
                                break;
                        case 50:cout<<"Dua ";break;
                        case 51:cout<<"Tiga ";break;
                        case 52:cout<<"Empat ";break;
                        case 53:cout<<"Lima ";break;
                        case 54:cout<<"Enam ";break;
                        case 55:cout<<"Tujuh ";break;
                        case 56:cout<<"Delapan ";break;
                        case 57:cout<<"Sembilan ";break;
                    }
        }

void satuan(int dgt){
    switch(dgt)
    {
        case 3:cout<<"Ribu ";break;
        case 6:cout<<"Juta ";break;
        case 9:cout<<"Milyar ";break;
        case 12:cout<<"Terliun ";break;
    }
    }

int main(){char* angka;
    awal:
    cout<<"Masukan Nominal Rp= ";cin>>angka;
    int d=strlen(angka)-1,i,batas=d,ang,bls;system("cls");
    for (i=0;i<=batas;i++,d--){
            ang=angka[i];
            if(ang<48||ang>57){system("cls");cout<<"Angka salah ! Masukan lagi\n";goto awal;break;}
            if(ang==49&&angka[i+1]!=48&&(d==1||d==4||d==7)){
                    bls=angka[i+1];
                    bilangan(bls,d);
                    cout<<"Belas ";i++;d--;
                                        }
            else {bilangan(ang,d);
                    if((angka[i]!=48)&&(d==1||d==4||d==7||d==10|| d==13)){cout<<"Puluh ";}
                    if((angka[i]!=48)&&(d==2||d==5||d==8||d==11)){cout<<"Ratus ";}
                    }
            if(ang!=48||angka[i-1]!=48||angka[i-2]!=48){satuan(d);}
                            }
    cout<<"Rupiah\n\n";
    cout<<"Rp= ";d=strlen(angka)-1;
     for (i=0;i<=batas;i++,d--){cout<<angka[i];
                            if (d==3||d==6||d==9||d==12||d==15){cout<<".";}}
    cout<<",-\n\n";
    system("pause");

    return 0;
    }

0 comments:

Post a Comment