#include <iostream.h>
#include <conio.h>
class Konversi{
      friend istream& operator>>(istream&, Konversi&);
      friend ostream& operator<<(ostream&, Konversi&);
public:
       Konversi(){};
       int j();
       int m();
       int d();
private:
        int jam;
        int menit;
        int detik;
        int sekon;
};
        int Konversi :: j(){
        jam=sekon/3600;
        return jam;
        }
        
        int Konversi :: m(){
        menit=(sekon-(3600*(sekon/3600)))/60;
        return menit;
        }
        
        int Konversi :: d(){
        detik=((sekon-(3600*(sekon/3600)))-(((sekon-(3600*(sekon/3600)))/60)*(60)));
        return detik;
        }
        
        
istream& operator>>(istream& in,Konversi& masukan){
         cout<<"*********************************************************"<<endl;
         cout<<endl;
         cout<<"* PROGRAM KONVERSI detik MENJADI FORMAT jam:menit:detik *"<<endl;
         cout<<endl;
         cout<<"*********************************************************"<<endl;
         cout<<endl;
         cout<<"masukkan waktu dalam detik: ";
         in>>masukan.sekon;
         cout<<endl;
         return in;
        }
ostream& operator<<(ostream& out,Konversi& keluaran){
        out<<keluaran.j()<<"jam : ";
        out<<keluaran.m()<<"menit : ";
        out<<keluaran.d()<<"detik: ";
        return out;
        }
int main(){
Konversi X;
cin>>X;
cout<<X;
cout<<endl;
cout<<endl;

    system("PAUSE");
    system("cls");
    return main();

}

Categories:

0 Response for the "Format Conversion From Seconds to Hours, Minutes, Seconds C++"

Post a Comment