Question: What am I doing wrong? C + + code below: A digital clock shows hours ( between 0 and 2 3 ) and minutes (
What am I doing wrong? C code below:
A digital clock shows hours between and and minutes between and Once a minute, it receives a pulse to advance the time. Complete the Clock class, using data members for the hours and minutes.
#include
using namespace std;
A simulated digital clock.
class Clock
public:
Sets the clock to :
void reset;
Advances this clock to the next minute.
void pulse;
Gets the hours of this clock.
@return the hours between and
int gethours const;
Gets the minutes of this clock.
@return the minutes between and
int getminutes const;
private:
int hours;
int minutes;
;
void Clock::reset
hours;
minutes;
void Clock::pulse
if minutes
minutes minutes;
else
hoursminutes;
minutesminuteshours;
int Clock::gethours const
return hours;
int Clock::getminutes const
return minutes;
int main
Clock myclock; myclock.reset;
for int i ; i ; i myclock.pulse;
cout myclock.gethours endl;
cout "Expected: endl;
cout myclock.getminutes endl;
cout "Expected: endl;
for int i ; i ; i myclock.pulse;
cout myclock.gethours endl;
cout "Expected: endl;
cout myclock.getminutes endl;
cout "Expected: endl;
for int i ; i ; i myclock.pulse;
cout myclock.gethours endl;
cout "Expected: endl;
cout myclock.getminutes endl;
cout "Expected: endl;
return ;
My output is the numbers are supposed to match the expected numbers:
Expected:
Expected:
Expected:
Expected:
Expected:
Expected:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
