Membuat Aplikasi Konversi Hijriyah Sederhana Dengan C++

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>

/*
* Author: Yakoeza911 (Golden Hands Group)
*  THIS SOURCE CODE IS FREE FOR USE IN
*  THE NAME OF ALLAH SUBHANAHU WA TA'ALA
*/

void main() {
// Deklarasi dulu yaa...
int sts = 1;
char *cbulan[] = {"Muharram","Safar","Rabiul Awal","Rabiul Akhir","Jamadil Awal",
"Jamadil Akhir","Rejab","Syaaban","Ramadhan","Syawal","Zulkaedah","Zulhijjah"};
char *gbulan[] = {"Januari","Februari","Maret","April","Mei","Juni","Juli",
"Agustus","September","Oktober","November","Desember" };

do {
int zjd, zl, zn, zj, bulan, hari, tahun, hr, bln, thn;
char input[16];
char *tok;

// sekedar tampilan awal
printf("\n");
printf("                                 MARHABAN..!!\n");
printf("                   APLIKASI KONVERSI MASEHI KE HIJRIAH  KE CINA\n");
printf("               +----------------------------------------------+\n");
printf("                \n");
printf("                   |\\___/|\n");
printf("                   )     (        ...:: Y A K O E Z A :::...\n");
printf("                  =\\     /=       _\n");
printf("                    )===(      __| | ___   ___  _ __  _  _\n");
printf("                   /     \\    / _  |/ _ \\ |__ \\| '_ \\| |/ /\n");
printf("                  |      |   | (_| | (_) |/ _ || | | |   < \n");
printf("                  /       \\   \\__,_|\\___/ |___||_| |_|_|\\_\\\n");
printf("                  \\   x   /\n");
printf("                   \\_____/\n");
printf("                \n");
printf("               +----------------------------------------------+\n\n");

// permintaan input
printf(" Masukkan tanggal masehi (hr/bln/thn): ");
scanf("%s",input);

// ngebagi string,
tok=strtok(input,"/");
hr=atoi(tok);
tok=strtok(NULL,"/");
bln=atoi(tok);
tok=strtok(NULL,"/");
thn=atoi(tok);

printf("\n Tanggal yang Anda masukkan: %d - %s - %d\n", hr, gbulan[bln-1], thn);

// mulai konversi tanggal yang di input
if ((thn > 1582) || ((thn == 1582) && (bln > 10)) || ((thn == 1582) && (bln == 10)
 && (hr > 14))) {
zjd=((1461 * (thn + 4800 + ((bln - 14) / 12))) / 4) + ((367 * (bln - 2 - 12 *
 (((bln - 14) / 12)))) / 12) - ((3 * (((thn + 4900 + ((bln - 14) / 12)) / 100)))
 / 4) + hr - 32075;
} else {
zjd= 367 * thn - ((7 * (thn + 5001 + ((bln - 9) / 7))) / 4) + ((275 * bln) / 9)
 + hr + 1729777;
}

zl=zjd - 1948440 + 10632;
zn=((zl - 1) / 10631);
zl=zl - 10631 * zn + 354;
zj=(((10985 - zl) / 5316)) * (((50 * zl) / 17719)) + ((zl / 5670)) *
 (((43 * zl) / 15238));
zl=zl-(((30 - zj) / 15)) * (((17719 * zj) / 50))-((zj / 16)) * (((15238 * zj)
 / 43)) + 29;
bulan=((24 * zl) / 709);
hari=zl-((709 * bulan) / 24);
tahun=30 * zn + zj - 30;

// output-nya
printf(" Konversi ke Hijriyah menjadi: %d - %s - %d H\n\n", hari,
 cbulan[bulan-1], tahun);

// tanya, mau ngulang
printf(" Coba lagi (0=false; 1=true): ");
scanf("%d",&sts);
if (sts==1) clrscr(); else printf("\n Tekan ENTER untuk keluar...");

} while(sts==1);

getch();
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: