0 like 0 dislike
1k 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
| 1k 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.70.174.240
©2016-2022

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
| 648 views
0 like 0 dislike
18 answers
[Exercise] Coding (C) - asked May 25, 2017 in C++
ID: 24828 - Available when: Unlimited - Due to: Unlimited
| 779 views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 700 views
0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked May 18, 2017 in C++
ID: 24769 - Available when: Unlimited - Due to: Unlimited
| 993 views
14,128 questions
220,831 answers
199,687 comments
5,462 users