Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code has already been written. Please describe what each line and each function does. I have to explain to someone else and I have

The code has already been written. Please describe what each line and each function does. I have to explain to someone else and I have a limited knowledge of C++

I have attached the instruction, the answer which is the code and the output the code gave. i want an explanation on the code on what each line is performing. I need the code to be explained.

#include

using namespace std;

class Converter

{

private:

int days, hours, minutes, seconds;

const int SECONDS_IN_7_DAYS = 604800; //60x60x24x7

public:

Converter()

{

days = 0;

hours = 0;

minutes = 0;

seconds = 0;

}

int getDays()

{

return days;

}

int getMinutes()

{

return minutes;

}

int getSeconds()

{

return seconds;

}

int getHours()

{

return hours;

}

void setSeocnds(int s)

{

if (s > SECONDS_IN_7_DAYS)

cout

else

seconds = s;

}

void convertSeconds(int s)

{

setSeocnds(s);

if (seconds % 86400 == 0)

{

days = seconds / 86400;

cout

}

else if (seconds % 86400 != 0)

{

if (seconds

{

if (seconds % 3600 == 0)

{

hours = seconds / 3600;

cout

}

else

{

hours = seconds / 3600;

seconds = seconds % 3600;

minutes = seconds / 60;

seconds = seconds % 60;

if (hours == 0)

cout

else if (minutes == 0)

cout

else

cout

}

}

if (seconds > 86400)

{

days = seconds/ 86400;

seconds = seconds % 86400;

hours = seconds / 3600;

seconds = seconds % 3600;

minutes = seconds / 60;

seconds = seconds % 60;

if (days == 0)

cout

if (hours == 0)

cout

else if (minutes == 0)

cout

else

cout

}

}

}

};

void main()

{

Converter secConvert;

int sec;

x:

cout

cin >> sec;

if (sec

goto x;

secConvert.convertSeconds(sec);

system("pause");//to hold the output screen

}

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

Solve the differential equation. y'' - 2y' + 10y = 0

Answered: 1 week ago

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago