Selasa, 30 Juni 2015

C++ Program JAM DIGITAL ( CLASS )

Program JAM DIGITAL bahasa C++ menggunakan CLASS

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <windows.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

class Simulator{
public :
Simulator();
int ambil_jam();
int proses();

private :
int jam, menit, detik;
};

Simulator::Simulator(){
}

int Simulator::ambil_jam(){
//deklarasi objek yang memanfaatkan class dan struct yang ada di library time.h
    time_t rawtime;
tm * timeinfo;
//proses pengambilan data waktu sistem
    time ( &rawtime );
timeinfo = localtime ( &rawtime );

//proses pemindahan data waktu sesuai dengan format ke dalam variabel
    jam=timeinfo->tm_hour;     //format untuk jam
    menit=timeinfo->tm_min;    //format untuk menit
    detik=timeinfo->tm_sec;    //format untuk detik
}

int Simulator::proses(){
while (true){
system ("cls");
cout<<"==========================================\n";
cout<<"||\t\t\t\t\t||\n";
cout<<"||\t\tJAM DIGITAL\t\t\ ||\n";
cout<<"||\t\t  ";
cout<<jam<<":"<<menit<<":"<<detik;
cout<<"\t\t||\n";
cout<<"||\t\t\t\t\t||\n==========================================\n\n";
Sleep(1000);
detik=detik+1;
if (detik>59){
detik=0;
menit=menit+1;
if(menit>59){
menit=0;
jam=jam+1;
if(jam>23){
jam=0;

}
}
}
}

}

int main(int argc, char *argv[]) {
Simulator digital;
digital.ambil_jam();
digital.proses();

return 0;
}

Hasil Compile :




Related Posts:

  • C++ PROGRAM DERET FIBONACCI ITERATIF C++ PROGRAM DERET FIBONACCI ITERATIF #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; void fibonacci(int N){ int U1 = 0, U2 … Read More
  • C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)C++ PROGRAM BILANGAN (terbesar, terkecil, rerata) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char … Read More
  • C++ Program Konversi Nilai UjianC++ Program Konversi Nilai Ujian #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { … Read More
  • C++ PROGRAM PERSAMAAN KUADRAT C++ PROGRAM PERSAMAAN KUADRAT  #include <iostream> #include <math.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int ar… Read More
  • C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL ( CLASS ) C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL  ( CLASS ) #include <iostream> #include <cstdlib> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") o… Read More

3 komentar: