Soal :
Source Code :
Program :
Source Code :
#include <iostream>
using namespace std;
class Waktu{
private:
int j1,m1,j2,m2;
int jamlama,menitlama,lama;
public:
Waktu()
{
}
void JamMulai()
{
cout<<"Mulai(jam,menit) ";
cin>>j1;
cin>>m1;
}
void JamSelesai()
{
cout<<"Selesai(jam,menit) ";
cin>>j2;
cin>>m2;
}
void ProsesMenittotal()
{
lama=(jamlama*60)+menitlama;
cout<<"Lama(menit) "<<lama<<endl;
}
void ProsesLama()
{
if(j1>j2)
{
j2=j2+12;
}
if(m1>m2)
{
j2=j2-1;
m2=m2+60;
}
jamlama=j2-j1;
menitlama=m2-m1;
cout<<"Lama(jam,menit) "<<jamlama<<" : "<<menitlama<<endl;
}
};
int main()
{
Waktu W;
W.JamMulai();
W.JamSelesai();
W.ProsesLama();
W.ProsesMenittotal();
return 0;
}
using namespace std;
class Waktu{
private:
int j1,m1,j2,m2;
int jamlama,menitlama,lama;
public:
Waktu()
{
}
void JamMulai()
{
cout<<"Mulai(jam,menit) ";
cin>>j1;
cin>>m1;
}
void JamSelesai()
{
cout<<"Selesai(jam,menit) ";
cin>>j2;
cin>>m2;
}
void ProsesMenittotal()
{
lama=(jamlama*60)+menitlama;
cout<<"Lama(menit) "<<lama<<endl;
}
void ProsesLama()
{
if(j1>j2)
{
j2=j2+12;
}
if(m1>m2)
{
j2=j2-1;
m2=m2+60;
}
jamlama=j2-j1;
menitlama=m2-m1;
cout<<"Lama(jam,menit) "<<jamlama<<" : "<<menitlama<<endl;
}
};
int main()
{
Waktu W;
W.JamMulai();
W.JamSelesai();
W.ProsesLama();
W.ProsesMenittotal();
return 0;
}
Program :