Selasa, 30 Juni 2015

Kodingan Jam Digital

Kodingan untuk Jam Digital di Dev++

#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include <ctime>
using namespace std;
void JamDigital();
int main()
{
system("color B1");
char Aktif;
do
{
cout<<"JamDigital"<<endl;
cout<<"[s] Tekan 's' Supaya Aktif"<<endl;
cout<<"Aktif: ";
cin>>("%c", &Aktif);
if (Aktif == 's' || Aktif== 'S')
{
JamDigital();
}
system("cls");
}
while (Aktif != 's' || Aktif !='S');
getch();
return 0;
}
void JamDigital()
{
int hh,mm,ss,ms,z;
hh=00;
mm=00;
ss=00;
ms=00;
z=1;
while(hh<=24 && z==1)
{ mm=0;
while(mm<=59 && z==1)
{ ss=0;
while(ss<=59 && z==1)
{ ms=0;
while(ms<=10 && z==1)
{
if(kbhit() != 1)
{
ms++;
Sleep(50);
system("cls");
time_t s=time(0);
tm t=*localtime(&s);
cout<<"      Tugas Proyek \n\n";
cout<<"ALGORITMA DAN PEMROGRAMAN\n";
cout<<"  JAM DIGITAL SEDERHANA\n\n";
cout<<"====================";
cout<<"\nJam\t: ";
printf("%02d:%02d:%02d\n\n",
t.tm_hour,
t.tm_min,
t.tm_sec);
cout<<"Tanggal : ";
printf("%02d-%02d-%04d",
t.tm_mday,
t.tm_mon+1,
t.tm_year+1900);
cout<<"\n====================";
cout<<"\n\n\nNAMA  : ";
cout<<"\nRamadanis Ambarsari\t\t NIM : 1400018235";
int a,b=0;
if(kbhit())
{
a = getch();
if(a == 80 || a == 112) //p
a= getch();
if(a == 67 || a == 99) //c
b = getch();
cout <<"a="<<a<<"b="<<b<< " ";
}
}
}
}
}
}
}

Hasil

1 komentar: