Question
In C++. Using the Following code, finish it adding a: Convert Into Seconds: the total 3 times runner Runner .cpp: #include runner.h #include Runner::Runner() {
In C++. Using the Following code, finish it adding a: Convert Into Seconds: the total 3 times runner
Runner .cpp:
#include "runner.h"
#include
Runner::Runner()
{
name = "";
hh = 0;
mm = 0;
ss = 0;
}
Runner::Runner(Runner& r)
{
name = r.name;
hh = r.hh;
mm = r.mm;
ss = r.ss;
}
// mutator
void Runner::set_name(string n)
{
name = n;
}
void Runner::set_time(int h, int m, int s)
{
hh = h;
mm = m;
ss = s;
}
// accessor
string Runner::get_name() {
return name;
}
void Runner::print(string pos) {
cout
}
// operator
bool operator
int t1, t2;
t1 = R1.ss + (60 * R1.mm) + (60 * 60 * R1.hh);
t2 = R2.ss + (60 * R2.mm) + (60 * 60 * R2.hh);
return t1
}
--------------------------------------------------------
runner.h
#ifndef RUNNER_H_
#define RUNNER_H_
#include
using namespace std;
class Runner {
private:
string name;
// time HH:MM:SS
int hh, mm, ss;
public:
// Constructor
Runner();
Runner(Runner& r);
// mutator
void set_name(string name);
void set_time(int h, int m, int s);
// accessor
string get_name();
void print(string pos);
// operator
friend bool operator
};
#endif
---------------------------------------------------------------------
main.cpp
#include
#include "runner.h"
using namespace std;
void get_runner_details(Runner& R) {
string name;
int h, m, s;
cout
cin >> name;
R.set_name(name);
h = m = s = -1;
cout
cin >> h;
while (h
cout
cout
cin >> h;
}
cout
cin >> m;
while (m
cout
cout
cin >> m;
}
cout
cin >> s;
while (s
cout
cout
cin >> s;
}
R.set_time(h, m, s);
cout
}
void print_results(Runner R1, Runner R2, Runner R3) {
if (R1
R1.print("first");
if (R2
R2.print("second");
R3.print("third");
}
else {
R3.print("second");
R2.print("third");
}
}
else if (R2
R2.print("first");
if (R1
R1.print("second");
R3.print("third");
}
else {
R3.print("second");
R1.print("third");
}
}
else if (R3
R3.print("first");
if (R1
R1.print("second");
R2.print("third");
}
else {
R2.print("second");
R1.print("third");
}
}
}
int main() {
Runner R1, R2, R3;
cout
get_runner_details(R1);
cout
cout
get_runner_details(R2);
cout
cout
get_runner_details(R3);
cout
print_results(R1, R2, R3);
return 0;
}
----------------------------------------------------------------------------------
i need the time HH,MM,SS been converter in Seconds and appear in the output.
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