Question: Please help me fix this codes: ....................................... #include #include class time { public: time(void); time(int hrs, int min, int sec); void input_time(); void print_12(); time

Please help me fix this codes:

.......................................

#include

#include

class time

{

public:

time(void);

time(int hrs, int min, int sec);

void input_time();

void print_12();

time operator-(time t);

private:

int hours,minutes,seconds;

};

time::time(void)

{

hours=99;

minutes=99;

seconds=99;

};

time::time(int hrs, int min, int sec)

{

hours=hrs;

minutes=min;

seconds=sec;

}

void time::input_time()

{

printf("Please enter the hour value:");

scanf("%d",hours);

printf("Please enter the minute value:");

scanf("%d",minutes);

printf("Please enter the second value:");

scanf("%d",seconds);

}

void time::print_12()

{

int thours=hours;

bool am=true;

if(hours>12)

{

thours=thours-12;

}

if(hours>=12)

{

am=false;

}

if(thours>9)

{

printf("%d:",thours);

}

else

{

printf("0%d:",thours);

}

if(minutes>9)

{

printf("%d:",minutes);

}

else

{

printf("0%d:",minutes);

}

if(seconds>9)

{

printf("%d:",seconds);

}

else

{

printf("0%d:",seconds);

}

if(am)

{

printf("am");

}

else

{

printf("pm");

}

}

time time::operator-(time t)

{

int t1sec=0, t2sec=0;

int second_difference;

int final_hours, final_minutes;

t1sec=t1sec+seconds;

t1sec=t1sec+(minutes*60);

t1sec=t1sec+(hours*60*60);

t2sec=t2sec+t.seconds;

t2sec=t2sec+(t.minutes*60);

t2sec=t2sec+(t.hours*60*60);

second_difference=abs((t1sec-t2sec));

final_hours=(second_difference/3600);

second_difference=second_difference-(final_hours*3600);

final_minutes=(second_difference/60);

second_difference= second_difference-(final_minutes*60);

time diff(final_hours,final_minutes,second_difference);

return diff;

}

int main(void)

{

time t;

time s;

time t1(12,40,16);

printf("The original time values are: ");

printf("Hours: 12 ");

printf("Minutes: 40 ");

printf("Seconds: 16 ");

printf("Please enter the new time: ");

t.input_time();

printf("New time value in 12 hour format");

t.print_12();

printf("Original time in 12 hour format");

t1.print_12();

s=t.operator-(t1);

printf("The difference between the two times is:");

s.print_12();

return 0;

}

........................................................

problem# 15.

Please help me fix this codes: ....................................... #include #include class time {

this is the error

public: time(void); time(int hrs, int min, int sec); void input_time(); void print_12();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!