menu
bartleby
search
close search
Hit Return to see all results

I'm not sure how to make the clock show just seconds of the day and the remaining time with this problem.Enhance Programming Exercise 9 by adding functions to the class clockType so that a program that uses this class can perform the following operations:Returns the elapsed time of the day of a clock in seconds.Returns the remaining time of the dayof a clock in seconds.Determines and outputs how far apart in time two clocks are. Outputs the time in the form hr:min:sec. Also, write a program to test yourclass.   clockType.hclockTypeImp.cppmain.cpp     class clockType { public:    void setTime(int hours, int minutes, int seconds);    void setHours(int hours);    void setMinutes(int minutes);    void setSeconds(int seconds);     void getTime(int& hours, int& minutes, int& seconds) const;     int getElapsedTimeOfDay();    int getRemainingTimeOfDay(); ​    int getHours() const   {        return hr;   }     int getMinutes() const   {        return min;   }    int getSeconds() const   {        return sec;   }     void printTime() const;     void incrementSeconds();     void incrementMinutes();     void incrementHours();     bool equalTime(const clockType& otherClock) const;     clockType(int hours, int minutes, int seconds);     clockType();  private:    int hr;  //variable to store the hours    int min; //variable to store the minutes    int sec; //variable to store the seconds  };

Question

I'm not sure how to make the clock show just seconds of the day and the remaining time with this problem.

Enhance Programming Exercise 9 by adding functions to the class clockType so that a program that uses this class can perform the following operations:

  • Returns the elapsed time of the day of a clock in seconds.
  • Returns the remaining time of the day
    • of a clock in seconds.
    • Determines and outputs how far apart in time two clocks are. Outputs the time in the form hr:min:sec. Also, write a program to test yourclass.
     
     
     
    • clockType.h
    • clockTypeImp.cpp
    • main.cpp
    •  
     
     
     
     
    class clockType
     
    {
     
    public:
     
       void setTime(int hours, int minutes, int seconds);
     
       void setHours(int hours);
     
       void setMinutes(int minutes);
     
       void setSeconds(int seconds);
     
     
       void getTime(int& hours, int& minutes, int& seconds) const;
     
     
       int getElapsedTimeOfDay();
     
       int getRemainingTimeOfDay();
     
     
       int getHours() const
     
      {
     
           return hr;
     
      }
     
     
       int getMinutes() const
     
      {
     
           return min;
     
      }
     
       int getSeconds() const
     
      {
     
           return sec;
     
      }
     
     
       void printTime() const;
     
     
       void incrementSeconds();
     
     
       void incrementMinutes();
     
     
       void incrementHours();
     
     
       bool equalTime(const clockType& otherClock) const;
     
     
       clockType(int hours, int minutes, int seconds);
     
     
       clockType();
     
     
    private:
     
       int hr;  //variable to store the hours
     
       int min; //variable to store the minutes
     
       int sec; //variable to store the seconds
     
     
    };
     
     
     
check_circleAnswer
Step 1
Note
Run the below program in "visual C++ editor" and name the corresponding files as
"Clock.h", "ClockTypeImp.cpp", and "main.cpp"
In "Clock.h", include two more functions such as "diff clk() " and
"printTime ) "
In "ClockType Imp.cpp", the functions "diff_clk()" and "printTime
|() " are implemented to print the difference between two clocks.
In "main.cpp", the function "diff clk( ) " and "printTime )" are
called to print the difference between two clocks.
27
help_outline

Image Transcriptionclose

Note Run the below program in "visual C++ editor" and name the corresponding files as "Clock.h", "ClockTypeImp.cpp", and "main.cpp" In "Clock.h", include two more functions such as "diff clk() " and "printTime ) " In "ClockType Imp.cpp", the functions "diff_clk()" and "printTime |() " are implemented to print the difference between two clocks. In "main.cpp", the function "diff clk( ) " and "printTime )" are called to print the difference between two clocks. 27

fullscreen
Step 2
//File name: clockType.h
class clockType
{
private:
int hr
int min
int sec;
public:
void setHours (int);
void setMinutes (int)
void setSeconds (int)
int getHours ()
int getMinutes ( )
int getSeconds ()
long int getElapsedTime )
long int getRemainedTime ();
//Add the following function to determine elapsed time
void diff_clk(clockType&);
void printTime ()
help_outline

Image Transcriptionclose

//File name: clockType.h class clockType { private: int hr int min int sec; public: void setHours (int); void setMinutes (int) void setSeconds (int) int getHours () int getMinutes ( ) int getSeconds () long int getElapsedTime ) long int getRemainedTime (); //Add the following function to determine elapsed time void diff_clk(clockType&); void printTime ()

fullscreen
Step 3
//File name: ClockType Imp.cpp
finclude <iostream>
#include "clockType.h"
using namespace std
1/set the hours
void clockType::setHours (int hours)
{
if (0 hours && hours <24)
hours
hr
else
hr =
07
//Set the minutes
void clockType: :setMinutes (int minutes)
{
if (0 <minutes && minutes <60)
min minutes
else
minutes 0;
//set the seconds
void clockType::setSeconds (int seconds)
if (0 seconds& & seconds <60)
seconds
sec=
else
07
sec =
}
//Return the hours
int clockType::getHours
t
return hr
help_outline

Image Transcriptionclose

//File name: ClockType Imp.cpp finclude <iostream> #include "clockType.h" using namespace std 1/set the hours void clockType::setHours (int hours) { if (0 hours && hours <24) hours hr else hr = 07 //Set the minutes void clockType: :setMinutes (int minutes) { if (0 <minutes && minutes <60) min minutes else minutes 0; //set the seconds void clockType::setSeconds (int seconds) if (0 seconds& & seconds <60) seconds sec= else 07 sec = } //Return the hours int clockType::getHours t return hr

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: what are the popular cost estimation techniques used for software cost estimation

A: Software cost estimation: Software cost estimation is a method or process that can help IT professio...

question_answer

Q: 3. Which command can you use to look for the file names status.report? Which command can you use to ...

A: The command used to look for files is ‘find’ command. Find command can be used with many criteria to...

question_answer

Q: This is for pygame Text Class The Text class inherits from Drawable and it will be used to display t...

A: Instructions for the Text class:Import the Drawable class and pygame module.Create a class Text and ...

question_answer

Q: 5-9) (Find the two highest scores) Write a program that prompts the user to enter the number of stud...

A: Program that prompts the user to enter the number of students and each student’s name and score, and...

question_answer

Q: Implement a recursive function called evens that returns an integer with only theeven numbers. Note ...

A: The evens function checks for the modulo 2 div value at each position of the input array and display...

question_answer

Q: As an IT manager, what strategy would you have followed to avoid the failed implementation of ERP sy...

A: ERP system:It denotes software for business process management that permits an organization in using...

question_answer

Q: Please write Lisp code for the following problem. Write a function that computes the surface area of...

A: Instructions to create a function that computes the surface area of a cylinder:Define a function nam...

question_answer

Q: Write a class, NumberToMonth, which does the following:a. Ask the user to enter the month of the yea...

A: The algorithm for the program would be as below:Declare one int variable for accepting user inputPro...

question_answer

Q: Develop the ‘Shape’ application such that: Implement an array of objects of various types (all SIX ...

A: Program plan:Define a class called “ShapeTest”.Define a “main()” method.Create an array of six shape...

Sorry about that. What wasn’t helpful?