Dibawah ini adalah coding c++/cpp console untuk mengkonversi tanggal


#include<iostream>
#include<conio.h>
#include<windows.h>

using namespace std;

char *bulan[]={"Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"};
char input[16],*tok,x;
int tgl(31),bln,thn,hari;

int convert(char input[16])
{
S:
    tok=strtok(input,"/");
    tgl=atoi(tok);
    if(tgl<=31)
    {
    }
    else {
        cout<<" "<<endl;
        cout<<" "<<endl;
        cout<<"                        TANGGAL ITU TELAH MELEBIHI "<<endl;
        cout<<" "<<endl;
        cout<<" "<<endl;
        getch();
        goto M;
    }
    tok=strtok(NULL,"/");
    bln=atoi(tok);
    if(bln<=12)
    {
    }
    else {
        cout<<" "<<endl;
        cout<<" "<<endl;
        cout<<"                        BULAN ITU TELAH MELEBIHI "<<endl;
        cout<<" "<<endl;
        cout<<" "<<endl;
        getch();
        goto M;
    }
    tok=strtok(NULL,"/");
    thn=atoi(tok);
    if(thn>=51 || thn<=99)
    {
        thn=2000+thn;
    }
    cout<<" "<<endl;
    cout<<"                        OUTPUT TANGGAL : "<<tgl<<" "<<bulan[bln-1]<<" "<<thn<<endl;
    getch();
    goto ULANG;
M:
    {
    system("cls");
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<"                  O)============================(O "<<endl;
    cout<<"                    | PROGRAM CONVERSI TANGGAL |"<<endl;
    cout<<"                  O)============================(O "<<endl;
    cout<<"  "<<endl;
    cout<<" "<<endl;
    cout<<"               NAMA : Hermanus Mau      NPM : 535120103 "<<endl;
    cout<<"         O)=================================================(O "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<"               INPUT TANGGAL(DD/MM/YY) : ";
    cin>>input;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    goto S;
    }
ULANG:
    {
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
        cout<<"               ULANG KEMBALI (Y/N)? : ";
        cin>>x;
        if(x=='y' || x=='Y')
        {
            goto M;
        }
        else if(x=='n' || x=='N')
        {
            return 0;
        }
        else
        {
            cout<<" "<<endl;
            cout<<" "<<endl;
            cout<<"                TRY AGAIN :"<<endl;
            cout<<"             O)==================================== "<<endl;
            cout<<"                => MAAF YANG ANDA MASUKAN SALAH!!! "<<endl;
            getch();
            goto ULANG;
        }
    }
}

int main()
{
    system("color A");
M:
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<"                  O)============================(O "<<endl;
    cout<<"                    | PROGRAM CONVERSI TANGGAL |"<<endl;
    cout<<"                  O)============================(O "<<endl;
    cout<<"  "<<endl;
    cout<<" "<<endl;
    cout<<"               NAMA : Hermanus Mau      NPM : 535120111 "<<endl;
    cout<<"         O)=================================================(O "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<" "<<endl;
    cout<<"               INPUT TANGGAL(DD/MM/YY) : ";
    cin>>input;

    convert(input);
    getch();
    return 0;
}


Semoga artikel  diatas dapat bermanfaat untuk anda.
Author image
About the Author :

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum.

Connect with him on :