0 like 0 dislike

The program below can compare time which is generated by class CTime but it seems not working properly. Please help to fix it. Remember that YOU CAN ONLY ADD YOUR CODE INSIDE THE SPECIFIC AREA

#include <iostream>
#include <cstdlib>
using namespace std;
class CTime
{
   private:
      int hour,min;
      double sec;

   public:

//Your code from here

 

//to here
};

int main(void)
{
   CTime t1(4,13,51.3);
   CTime t2(5,44,30.3);
   
   if(t1>t2)
      cout << "t1 is larger than t2" << endl;
   else
      cout << "t2 is larger than t1" << endl;

   if(t1<t2)
      cout << "t1 is smaller than t2" << endl;
   else
      cout << "t2 is smaller than t1" << endl;
   
   system("pause");
   return 0;
}

 

[Exercise] Coding (C) - asked in C++
Available when: Unlimited - Due to: Unlimited
| 72 views
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help

26 Answers

0 like 0 dislike
Hidden content!
#include ** * ** *** ** * *

#include * ** *

using namespace std;

class CTime

{
**** ** * ** * *
** ******** ** * * * ***** * ** hour,min;
* ***** * * ** * * * * * * * * sec;


* * ***** * * *** * ***



//Your code from here
*** * * ****** * **** * * h, int m, double s){
******* * * * * * * **** *** = h;
** ** * *** * * * *** * ** * * ** = m;
***** * * * * * * **** ** * ** * * = s;
* ***** ** ***


* ****** ** * * * bool * ** * ** (const CTime * * * const CTime * ** * *
** * ** ** **** * *** * * * * **** ** *** * ** + num1.min + ** ** > ** + num2.min + * **
** ** **** * * *


******** *** * ** ** ** bool * * ** ** (const CTime ***** const CTime ****
** ** *** ***** * ***** ** * * * * ** * * ** + num1.min + num1.sec) < * * *** + num2.min + ** **
****** * * ***



//to here

};



int ******

{
* ** * *** ****** * * ** ***
**** * * * * * **** * *


*** * ** ** ** ** * * **
* * * ** * **** * ** ** * * *** ** is larger than * ** ** * ** endl;
** ** *** *** * *
* * * * ** ****** *** **** **** * * ** ** * * ** * is larger than * ** * * * * ** endl;


** * * **** ******** * *
*** ** * *** * * * * * ***** * ** * * ** ** is smaller than ***** * * * ** endl;
*** ** ** **
* ** ** * * * ***** * ** *** * ** * * * *** * is smaller than *** * ** ** *** ** * endl;


***** * * ** *** * * * * ** **
* * * ***** *** * *** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include **** * ****

using namespace std;

class CTime

{
** * **** ** ******
* ** * * ** ** ** ** * hour,min;
** *** *** * * ** * * * ** * ** sec;


* * * * ** *** * *



//Your code from here
* * ** ******* *** ** h, int m, double s){
* * ** * *** * *** * * ** *** ** * * = h;
****** ** ** ** ** *** * * * * *** * ** = m;
*** * * * ** * * *** * * *** * * * * = s;
* * * *** ** * *


*** * **** ***** *** ** * bool ** (const CTime *** * * * const CTime *** * * *
** * **** ***** * * * ** ***** * *** ** * * * + num1.min + *** * > * * + num2.min + * **
***** **** ** ** **


* * ** **** bool * ******* (const CTime ** ** * ** const CTime ** **** * ***
** ** *** * * * * * *** * * ****** * * *** + num1.min + num1.sec) < * ** ***** + num2.min + * *
* * * * **



//to here

};



int * * **

{
* *** * ** *** * * *****
* * ******* * ** **


*** ** * ** ** ** ** *** **
* ******* ** * * * **** ** ***** * ** * * *** ***** is larger than * * ** ** * ** * ** endl;
* * * ** * * *
* **** * * * * * ***** * * * *** ** ** ***** is larger than *** * * ** * * * ** endl;


**** * * * * * ** *** * * **
***** *** * ** * ** * ** *** * * *** ** * * * * is smaller than ***** * * ** * endl;
*** * * *** * *** ** *
***** ** **** * * ** * * ** *** * ** *** *** * ** * * is smaller than ** * * * ***** * endl;


* * * ***** ** * * **** * * * * * ***
* ********* * * * ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include * ***** **

using namespace std;

class CTime

{
* **** * ** * * ***
* * * ** * ** ** ** * * ***** hour,min;
* * **** *** *** * * * *** * ** * sec;


** **** *** * * ** *



//Your code from here
* * ***** *** * ** *** h, int m, double s){
* *** ** * ***** **** ** ** * * ** **** * ** = h;
*** ** * * ** *** ** ******* * * * *** = m;
* * ***** ** ** *** *** *** * ** *********** ** = s;
**** * * *** ** ** *


**** * * bool ** ** ** * (const CTime * const CTime ** * **
** * ** ** *** * * * ** ** * * * ** ** * *** * + num1.min + ** > **** + num2.min + * * *
* * * * * * ** *


* * ** ** *** **** bool ** * **** (const CTime * * * const CTime * * *
* * ** **** * * ** * ** * * * * ** ** ** * * * + num1.min + num1.sec) < ***** + num2.min + * **
* * ** ****



//to here

};



int * *

{
* * * * * ** * *** **
** *** ******** * ******


* ** *** * * * *
* ** ** *** * ** ** ** ** ** ** ** * * ** *** * is larger than ** ** * *** endl;
* **** * ** * ****
* * ** * * * *** ***** *** **** * * * ** * ** * * * ** is larger than ** * * ** * * * endl;


* * * *** ** * * *
* ** * ** *** * * * ** * ** * ** * ** ** * * ** is smaller than * *** *** * endl;
********* * * * ****
* * ** * *** * ** ** * ***** * * * ** ** *** * * * *** is smaller than ** * * *** *** endl;


** ** * * *** *** ******* **
* *** * * * * * ** * ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include * * ****

#include * ** ** *

using namespace std;

class CTime

{
** * * * ** * **
** ** ** * *** *** * ** ***** * ***** hour,min;
** ** * ** ** * * * * * * *** * * sec;


* * * * **** *** *** *
*** ** * * * **** * * * * * * ***** * * x,int y,double z){
** * * ***** * * * * *** ** * ** * ***** * ** ** ***** * *** = x;
* *** ** ****** * * ******** ** * ** ** ** * ** ** ** * ***** * * = y;
* * * * * * * *** * * * *** * ** ** ****** * * *** * * *** ** = z;
* ** *** **** * ** * *** * * * ** *** ** *
* * * * ** * * ** * **** **** * * bool * *** * **** * *** * X, const * ** Y);

* * * *** * **** **** ** * * * bool * * *** X, const * * * * Y);

};



bool operator < (CTime * *** lhs, CTime *** rhs)

{
* ** *** ** * **** * ** lhs.hour < rhs.hour;

}



bool operator > (CTime * ** *** * lhs, CTime ** *** ** rhs)

{
**** *** ******* *** ** **** lhs.hour > rhs.hour;

}



int main(void)

{
* ** * * * * ** ***
* **** * * ***** ** * ** ** *
* * * ** * * *
*** ** ** * * * * ***
* * **** * * ** **** ** ** ** ** *** * * * ** * ** ** * is larger than * * * * ** endl;
*** * * ** ** * ****
* * ** * * ***** * * * * ** ******* * ****** ** ******* is larger than * **** ** * * endl;


* * * ***** * *** * * * *
** * * ** * ** ****** ** * **** * * is smaller than * ** ** ** endl;
* * * * * * **
* * * * ** *** * **** * *** * "t2 is smaller than * *** **** * endl;
* * ** *
* ** *** ****** * * * ** ** * * **
*** ***** * ***** 0;

}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include * *** *** **

#include * ***

using namespace std;

class CTime

{
******* * **** **** * * *
** ** * * ****** * * *** hour,min;
* * * * * ** ** * ** * * * ** sec;


* ** ** *** * * ** ***



//Your code from here
***** ** * *** * h, int m, double s){
* * * ** * ** ***** * * * ******* = h;
* ** ** * * * * ***** ** ** **** = m;
* ** * ** **** ***** *** ***** * *** = s;
* ** * * * * ** *


* ** ** * * ***** ** * bool * * * (const CTime * ** const CTime ** ** ** *
*** *** * * *** * ** * ** ** * * ** *** *** + num1.min + num1.sec) > * ** + num2.min + ** ***
* ** * ****


**** ** * **** * * * bool ****** ** (const CTime ** * * ** const CTime *** **
***** ** * * * * *** * ** * **** * * ** **** ** + num1.min + num1.sec) < ** **** + num2.min + *** *
* *** ** ** ** * *



//to here

};



int ***

{
**** * * ******** *
* *** * ** * *** ** **** * **


* * * * *** ** ** *
** *** * * ** * * ** * * ** * * *** ** * * ***** ** * * * * is larger than * * * * *** endl;
* ** ** * * * * *
* * *** **** **** ** * * **** **** * *** * * ** * is larger than *** * * * ** endl;


**** * ** *** * * **** **
*** * **** * ** * * *** * * ** ** *** * ** ** * * * **** ** * is smaller than ** ** ** ** * endl;
*** * * * ** * **
* ** ** *** * *** *** * * * * * * *** ** is smaller than ** ** *** * * * * endl;


* *** ******* * *** *** * ***
* * * ** ** * 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
#include **** ***

using namespace std;

class CTime

{
** * **** * ** *** *
* * * * ** * ** * * * ** * ** hour,min;
**** ** ** ** * *** ** * * ** *** sec;


* * * ** * ***** ***



//Your code from here
* ** * *** * * *** ** h, int m, double s){
* * ** ** *********** *** ***** * * * = h;
* **** * * ** * * * ** *** ** = m;
*** **** * **** * ****** ***** * ** * = s;
**** ** ***** ****


* * **** *** ** * * * bool **** ** * (const CTime * * ** *** const CTime ** * *
* ** * * * ***** * * * **** * ** + num1.min + > * ***** + num2.min + **** *
*** * * *


** ** ** ** *** bool * ****** (const CTime * * * const CTime ** *** * *
* **** * * ***** *** * **** * *** * * * *** + num1.min + num1.sec) < * * * + num2.min + ****
**** * * * **



//to here

};



int *** * *

{
* ***** ***** * ** *** * * * **
** ** * * ** *** * * * *


**** * ** * * * * *
* ** *** * * * * * ** * * * * * * * ** is larger than ** **** **** endl;
******* * ** *
** ****** ** ** * * ******* ** * *** * * ** is larger than ** ** ** * * * ** ** endl;


* * *** ******* **
***** * ** ** ** ** ** * ** ** * * *** * *** is smaller than * ** ** endl;
******* ** * ****
* ** * * * * ** * ***** * * *** ** is smaller than * * * *** **** endl;


* *** * ***** *** ***** * ** * *
*** * ** * * ** * ** 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
#include *** * * * * ** **

#include ** * * ******

using namespace std;

class CTime

{
* ** * * *** *
***** * * ******** * * *** ** * *** *** * hour,min;
* * * *** *** * ****** * * * *** * sec;


** * * * * * * * *
**** * * * *** ** ** * ** **** * * ** ** ** * * x,int y,double z){
* * ** * *** *** * ** * * ****** * * ** **** ** *** = x;
* ** * ** ** **** *** ** * * * ** ** *** * ** = y;
** * **** ** * *** * * ** ***** ** * * ** * ** * * * ** * * = z;
* ***** * * * *** * ** * *** * *** ***
*** ** * ** *** *** * ** * * ** * bool ** *** * ** * * ** * * X, const ** * **** Y);

** ** ***** * ** *** ******** **** * * * bool ** **** *** ** ** X, const ** ** Y);

};



bool operator < (CTime ** ** lhs, CTime **** * rhs)

{
* * * ** *** ****** * lhs.hour < rhs.hour;

}



bool operator > (CTime * *** ** lhs, CTime * ** ** rhs)

{
* * * * ** ***** *** **** *** lhs.hour > rhs.hour;

}



int main(void)

{
* *** *** ***** * * * **
*** *** * ****** * * * * ** ***
* * ** ** **** *
****** **** * *** *
** * * **** * * * ** * ** * ** **** * *** ** * * * is larger than * * * *** endl;
****** * *** *
**** * * ** * * * * ** * * ** * * * * ** *** ** *** ** is larger than * *** * ** * *** endl;


*** * * *** ** ****
* **** ** * * ** ** * * *** * * ** ** is smaller than ** *** * * endl;
* ** * *** ****** * *
*** ** * *** * * ** ** ** ** * **** ** ** ** * "t2 is smaller than **** * * ** * endl;
* * * *** ***
* ***** * * **** * * * ** ** ** *
** * * ** * * * 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include * * * * * **

using namespace std;

class CTime

{
* * * * ** ** * ***** ** ** *
* *** ** *** * * * *** ** hour,min;
** * * ****** *** **** * ** *** sec;


* **** ** * * * ***



//Your code from here
*** ** * ***** * * * h, int m, double s){
** *** * * * * * * * * ******** * = h;
* ** * * **** * * * * ** * * * * * * = m;
* * *********** * ****** ** *** ** ** * * = s;
* *** * * ** * ** *


* * ** ** *** * ** * bool * ** * * ** * (const CTime ** *** const CTime * * *
* **** * ** * * * * * ** ** * * ****** + num1.min + * > * * * * + num2.min + *
*** * * * *** **


* **** *** * ** *** ** bool * ** ** (const CTime * * const CTime * **
* *** * ** ** * ** *** * * * ***** * * *** * * + num1.min + num1.sec) < ** + num2.min + ** ****
*** ** * * ** * *



//to here

};



int *** ****

{
* * *** * *** **** *
**** * * ***** **** * *** * ** *


** ****** **** * * * *
* * ** ** * ** * *** * **** ** * *** ** ***** * is larger than * * ** * *** * * endl;
* ** * * * * *
** ** ** *** ** ** * ** * * * ** ** * *** * is larger than * ** * * ** endl;


** ** **** * * * **
* ** **** * ** * *** ** **** * * ** ** ** * is smaller than * * * * ** ****** endl;
* * * * ** **
* ***** ** * ***** *** * * ***** ** * * ***** * ** is smaller than ** ** * * * * * *** endl;


* * * **** * ** * * * ** ** *** ***
***** ** * * * ** 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include **** *** ***

using namespace std;

class CTime

{
* ** *** ******** * *
** * * * *** ******* * *** ** *** * hour,min;
*** ** ** * **** * * ** *** *** ** sec;


** * * * ** * *** **



//Your code from here
* * * ** * *** * * * h, int m, double s){
*** ** ** * ** * * ******* ****** ** = h;
* ***** **** * * ** * ****** ** * * = m;
** * *** * ** * ** *** * * = s;
*** * * * * ** *


* ***** ** bool * ** * ** * (const CTime ** * * ** const CTime ******* *
* ** * * * ** * * ** * * * ** * *** + num1.min + * * > * + num2.min + **
***** **** * * **


*** * ** ** * * * **** bool ** *** (const CTime *** ** * const CTime **** *
* ** * ** * * * * * * **** * ** * + num1.min + num1.sec) < ** + num2.min + **
** * *** * *** **



//to here

};



int * *****

{
* ** *** * ** *** ** **
* ** * *** * * ** **


* ** ** ******** * *** * ***
*** ** **** * * *** * *** **** ** * *** *** ** * is larger than *** * * * ** *** * *** endl;
* **** * * * * **
** ** * ** * * **** *** * *** *** * * ** * ** * * * * is larger than ***** ** * endl;


**** * * * ** * *** **
* ** ****** * ** * *** * * ** *** ** * * ** * ** * * is smaller than * ** * endl;
**** ** ** * *
* * * *** * **** * ****** * * * * ** *** * is smaller than ***** * * * ** ** *** * endl;


*** * **** * * ** ** * * * * * * ** **
******* ***** ** ** * 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include ***** *

using namespace std;

class CTime

{
* ** **** * ** * *
* ****** ** ** * ** * * **** *** * hour,min;
* *** **** * ** *** * ****** * * *** sec;


* * ** ** * ** **



//Your code from here
*** ** *** * * * * h, int m, double s){
* *** **** **** * *** **** *** * ***** ** = h;
* *** **** * * ** ** *** ** * *** * * = m;
* * **** ** ** * * * * ***** * = s;
* ***** ** ** * *


** * ***** * * ** bool ** * * (const CTime ** const CTime * ** *
* *** * * * * * * * **** ** ** ** ** * * + num1.min + > * **** + num2.min + **
* ****** * **


* * * **** * ** * bool * * * (const CTime * *** * * const CTime ** *
* * * * *** * * ** * **** ** *** ** ** ** ** * ** + num1.min + num1.sec) < ** + num2.min + *******
* ** *** ** ** **



//to here

};



int ***

{
* * * * * * * * * * *
* *** * * * * *** *** *


** * * ** * ** ** * *** *****
* * ** ** ******* * ** * ** ** **** *** ** * ** is larger than *** * ** * * ** endl;
* * *** * * *** * ** *
* * * *** ** * * ** * * * * * *** * * *** is larger than * * * *** * * ** * endl;


* ** **** * * ** ***** * **
** * * *** *** * * ** * * * ** * * ** ** is smaller than * ** * * * endl;
* ****** * * *
* *** * *** * * *** * ****** *** * * **** * * * * is smaller than ** ** * *** * * endl;


* *** * ** * **** * * * * *** **
*** ** * * ***** 0;

}
answered by (-215 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.79.185
©2016-2019

Related questions

0 like 0 dislike
15 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
Available when: Unlimited - Due to: Unlimited
| 44 views
0 like 0 dislike
18 answers
[Exercise] Coding (C) - asked May 25, 2017 in C++
Available when: Unlimited - Due to: Unlimited
| 79 views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
Available when: Unlimited - Due to: Unlimited
| 68 views
0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked May 18, 2017 in C++
Available when: Unlimited - Due to: Unlimited
| 74 views
9,248 questions
85,575 answers
63,421 comments
2,713 users