Results 1 to 6 of 6
http://idgs.in/185031
  1. #1
    -GajahLampung-'s Avatar
    Join Date
    Nov 2008
    Location
    Penangkaran Gajah
    Posts
    1,069
    Points
    1,449.20
    Thanks: 0 / 4 / 4

    Default membuat kalender with C++, buat kalender sendiri yuk

    nih script na..


    tinggal d jalankan menggunakan borland C++

    Code:
    #include <conio.h>
    #include <iostream.h>
    #include <iomanip.h>
    #include <dos.h>
    
    void kalender (long *hari, int n);
    void tanggal(int *tgl,int *bln, int *thn);
    void getdate (struct date *tanggal);
    
    int main()
    {
    	int tgl, bln, thn;
    	int tglc, blnc, thnc;
    	int show=0;
                  int i;
    	long hari=0;
    	char tombol;
    	
    	//mengambil data tanggal hari ini
    	tanggal(&tgl, &bln, &thn);
    	tglc=tgl;
    	blnc=bln;
    	thnc=thn;
    	
    	do
    	{
    	hari=0;
    	clrscr();
    	cout << endl;
    	cout << endl;
    	cout << "\t\t\t		Kalender";
    	cout << endl << endl;
    	
    	//menampilkan tanggal
    	cout << " Today : " << tglc << ' ';
    	if (blnc==1)
    		cout << "Januari";
    	else if (blnc==2)
    		cout << "Februari";
    	else if (blnc==3)
    		cout << "Maret";
    	else if (blnc==4)
    		cout << "April";
    	else if (blnc==5)
    		cout << "Mei";
    	else if (blnc==6)
    		cout << "Juni";
    	else if(blnc==7)
    		cout << "Juli";
    	else if (blnc==8)
    		cout << "Agustus";
    	else if (blnc==9)
    		cout << "September";
    	else if (blnc==10)
    		cout << "Oktober";
    	else if (blnc==11)
    		cout << "November";
    	else if (blnc==12)
    		cout << "Desember";
    	cout << ' ' << thnc;
    	
    	if (show)
    		{
    			cout << "\t\t\t				  <R>emove Menu";
    		}
    	else
    		cout << "\t\t\t				  <S>how Menu";
    	
    	cout << endl << endl;
    	cout << "\t\t			  " << setw(9);
    	
    	if (bln==1)
    		cout << "Januari";
    	else if (bln==2)
    		cout << "Februari";
    	else if (bln==3)
    		cout << "Maret";
    	else if (bln==4)
    		cout << "April";
    	else if (bln==5)
    		cout << "Mei";
    	else if (bln==6)
    		cout << "Juni";
    	else if(bln==7)
    		cout << "Juli";
    	else if (bln==8)
    		cout << "Agustus";
    	else if (bln==9)
    		cout << "September";
    	else if (bln==10)
    		cout << "Oktober";
    	else if (bln==11)
    		cout << "November";
    	else if (bln==12)
    		cout << "Desember";
    	cout << ' ' << thn;
    	cout << endl << endl;
    	
    	//menghitung banyak hari dari tanggal 1 januari 1900 sampai tanggal sekarang
    	for (int i=1900; i<thn; i++)
    		{
    			if (i%4==0)
    				hari+=366;
    			else
    				hari+=365;
    		}
    		
    	for (i=1; i<bln; i++)
    		{
    			if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
    				hari+=31;
    			else if (i==4 || i==6 || i==9 || i==11)
    				hari+=30;
    			else if (i==2 && thn%4==0)
    				hari+=29;
    			else 
    				hari+=28;
    		}
    	
    	//menampilkan kalender
    	i=bln;
    	if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
    		kalender(&hari,31);
    	else if (i==4 || i==6 || i==9 || i==11)
    		kalender(&hari,30);
    	else if (i==2 && thn%4==0)
    		kalender(&hari,29);
    	else 
    		kalender(&hari,28);
    	
    	//menampilkan menu
    	if (show)
    		{
    			cout << endl << endl;
    			cout << "		<U> Next Year	   <K> Next Month	   <G>Goto	<E>exit" << endl;
    			cout << "		<J> Previous Year   <H> Previous Month   <A>About" << endl;
    		}
    	else
    	;
    	
    	//menunggu penekanan tombol keyboard
    	tombol=getch();
    	
    	//jika penekanan tombol telah dilakukan
    	if (tombol=='u' || tombol=='U')
    		thn++;
    	else if (tombol=='s' || tombol=='S')
    		show=1;
    	else if (tombol=='r' || tombol=='R')
    		show=0;
    	else if (tombol=='h' || tombol=='H')
    		if (bln==1)
    			{
    				bln=12;
    				thn--;
    			}
    		else
    			bln--;
    	else if (tombol=='j' || tombol=='J')
    		thn--;
    	else if (tombol=='k' || tombol=='K')
    		if (bln==12)
    			{
    				bln=1;
    				thn++;
    			}
    		else
    			bln++;
    	else if (tombol=='e' || tombol=='E')
    		goto exit;
    	else if (tombol=='a' || tombol=='A')
    		{
    			clrscr();
    			cout << endl << endl;
    			cout << "			   Program Kalender 1.04" << endl;
    			cout << "	 Duken Marga Turnip ([email protected])" << endl << endl;
    			cout << "		  compiled with Turbo C++ 1.01" << endl;
    			cout << "		   edited with Notepad++ 5.03" << endl;
    			cout << "				1 Januari 2008" << endl;
    			cout << " How to Use :" << endl;
    			cout << " When you run this program, it will display the currently month in" << endl;
    			cout << "  your computer. You can also see other month or year by pressing" << endl;
    			cout << "  key like 'U' to see next year, 'H' to see prevoius month, etc. " << endl;
    			cout << "  Use it with your right hand like using arrow keyboard ^.^" << endl << endl;
    			cout << "\t\t" << "   U" << endl;
    			cout << "\t\t" << "H  J  K" << endl << endl;
    			cout << "  You can also go to date you want in menu Go To and fill the month "  << endl;
    			cout << "  and year you want to see." << endl;
    			cout << "  This calendar can display the date from 1 January 1900 up to the future." << endl;
    			cout << "  hehehe..." << endl << endl;
    			cout << "		  Press any key to go back..";
    			getch();
    		}
    	else if (tombol=='g' || tombol=='G')
    		{
    			clrscr();
    			cout << endl << endl << endl;
    			cout << "  GO TO..." << endl << endl;
    			do
    			{
    				cout << "  Month : ";
    				cin >> bln;
    			} while (bln<1 || bln>12);
    			do
    			{
    				cout << "  Year  : ";
    				cin >> thn;
    			} while (thn<1900);
    			
    		}
    	else
    	;
    	} while (1);
    	
    	exit:
    	return 0;
    }
    
    void kalender (long *hari, int n)
    {
    	cout << "	 MINGGU	 SENIN	 SELASA	 RABU	 KAMIS	 JUMAT	 SABTU ";
    	cout << endl << endl;
    	for (int i=1; i<=n; i++)
    		{
    			int angka=0;
    			angka=*hari%7;
    			if (i==1)
    				cout << setw((angka+1)*10) << i;
    			else
    				cout << setw (10) << i;
    			(*hari)++;
    			if (angka==6)
    				cout << endl << endl;
    		}
    }
    
    void tanggal (int *tgl,int *bln, int *thn)
    {
    	struct date tanggal;
    	getdate(&tanggal);
    	*tgl=(int) tanggal.da_day;
    	*bln=(int) tanggal.da_mon;
    	*thn=tanggal.da_year;
    }
    Sumber:www.bluecheatah.com
    Last edited by -GajahLampung-; 12-04-09 at 09:44.

  2. Hot Ad
  3. #2
    ditatompel's Avatar
    Join Date
    Apr 2008
    Location
    Semarang, Jogja, Surabaya... Sak karepku....
    Posts
    308
    Points
    402.20
    Thanks: 0 / 2 / 2

    Default

    Lah?? klo mo nambahin script buat background bisa ga?? di kasi sebelah mananya??
    Quote Originally Posted by ditatompel View Post
    lets play truth and dare, or just play dare cause no one tells the truth anymore

  4. #3
    Trademaks's Avatar
    Join Date
    Oct 2006
    Location
    Indonesia
    Posts
    1,946
    Points
    3,106.70
    Thanks: 3 / 3 / 3

    Default

    sumbernya ??

    sekalian donk dijelaskan source codenya..

    jangn hanya paste aja.. he8x

  5. #4
    LuCkyM3's Avatar
    Join Date
    May 2008
    Location
    I am flying.
    Posts
    952
    Points
    1,140.40
    Thanks: 0 / 1 / 1

    Default

    bukannya ini mestinya di subforum programming??

  6. #5
    abcx's Avatar
    Join Date
    Oct 2007
    Location
    H0Me
    Posts
    1,373
    Points
    1,922.70
    Thanks: 0 / 5 / 4

    Default

    ada yg salah tuh code na..

    #include <conio.h>
    #include <iostream.h>
    #include <iomanip.h>
    #include <dos.h>

    void kalender (long *hari, int n);
    void tanggal(int *tgl,int *bln, int *thn);
    void getdate (struct date *tanggal);

    int main()
    {
    int tgl, bln, thn;
    int tglc, blnc, thnc;
    int show=0;
    int i;
    long hari=0;
    char tombol;
    kurang int i;
    (dah diQuote tuh)
    Cinta DiMulai dengan SeBuah Senyuman,
    BerTumbuh dengan SeBuah Ciuman,
    dan BerAkhir dengan Tetesan Air Mata [KeSedihan] . . .
    >_<

  7. #6
    djockeyz's Avatar
    Join Date
    Jul 2008
    Location
    di rumah laa
    Posts
    695
    Points
    835.70
    Thanks: 0 / 0 / 0

    Default

    wah...lumayan nih dapet plajaran baru.. hehe.. thx men...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •