0 like 0 dislike
1.8k views

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++
ID: 24827 - Available when: Unlimited - Due to: Unlimited
| 1.8k 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)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.216
©2016-2024

Related questions

0 like 0 dislike
15 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24854 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
18 answers
[Exercise] Coding (C) - asked May 25, 2017 in C++
ID: 24828 - Available when: Unlimited - Due to: Unlimited
| 1.5k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked May 18, 2017 in C++
ID: 24769 - Available when: Unlimited - Due to: Unlimited
| 1.8k views
12,783 questions
183,443 answers
172,219 comments
4,824 users