Question
C++ Question: The first image is the assignment given, and the second & third images are sample codes for the assignment's solution. Explain in detail,
C++ Question: The first image is the assignment given, and the second & third images are sample codes for the assignment's solution. Explain in detail, (almost) line-by-line, what is happening in the program, as if you are teaching someone who never programmed before. You are welcome to include comments next to the lines using "//" operater in the program. Included below the images is the program in text form. Remember to explain in FULL detail.
#include
using namespace std;
class Seconds {
private:
unsigned int inputSeconds;
unsigned int days;
unsigned int hours;
unsigned int minutes;
unsigned int seconds;
public:
Seconds(unsigned int sec) {
inputSeconds = sec;
days = 0;
hours = 0;
minutes = 0;
seconds = 0;
}
void setSeconds(unsigned int sec) {
inputSeconds = sec;
}
unsigned int getInputSeconds() {
return seconds;
}
unsigned int getDays() {
return days;
}
unsigned int getHours() {
return hours;
}
unsigned int getMinutes() {
return minutes;
}
unsigned int getSeconds() {
return seconds;
}
void convertInputToDayHrMinSec() {
seconds = inputSeconds;
days = seconds / (24 * 60 * 60);
seconds = seconds % (24 * 60 * 60);
hours = seconds / (60 * 60);
seconds = seconds % (60 * 60);
minutes = seconds / 60;
seconds = seconds % 60;
}
bool weekCalculation() {
if (inputSeconds > (7 * 24 * 60 * 60))
return false;
else
return true;
}
};
int main() {
int seconds;
cout
cin >> seconds;
while(seconds
cout
cin >> seconds;
}
Seconds s(seconds);
if(!s.weekCalculation()) {
cout
}
else {
s.convertInputToDayHrMinSec();
if(s.getDays() > 0)
cout
if(s.getHours() > 0)
cout
if(s.getMinutes() )
cout
if(s.getSeconds() )
cout
}
}
SHORT PROGRAMMING TASKS: :Object Orientated Programming Use Object Oriented Design (OOP), Use Constructors, Parameters, and arguments as needed Have the user input number of seconds. Convert number of seconds to days, hours, minutes, and remaining seconds up to 7 days. If the number of seconds is greater than 7 days do not convert and print a message "user entered seconds greater than 7 days." Create a main function to control the operation of the program. If the user inputs a second amount for conversion less than or equal to 0 the program should prompt the user again for input. Implement setter and getter method Only output days if there are enough seconds for 1 day needed . Days Hours e Minutes Seconds Only output hours if there are enough seconds for 1 hour Hours e Minutes Seconds Only output minutes if there are enough seconds for 1 minute Minutes * Seconds Attach Snipping Photo of Source Code and Output below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started