Question

C++ programining exercise

2. Do Chapter 10's Programming Exercise 8, using t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: Main.cpp #include <10 stream> #include <time.h> #include clockTypeEnhanced.h using namespace sta? int main () time_

Program code:

Main.cpp:

#include <iostream>

#include <time.h>

#include "clockTypeEnhanced.h"

using namespace std;

int main ()

{

time_t s, e;

double Tdiff;

clockTypeEnhanced c;

time (&s);

for (int i=0;i<5;i++)

{

cout<<ctime(&s);

c.elapsed(1);

}

time (&e);

Tdiff = difftime(e,s);

cout<<"Elapsed time in seconds"<<Tdiff;

return 0;

}

clockTypeEnhanced.cpp:

#include <time.h>

#include "clockTypeEnhanced.h"

void clockTypeEnhanced::elapsed ( int sec )

{

           clock_t ew;

           ew = clock () + sec * CLOCKS_PER_SEC ;

           while (clock() < ew) {}

}

clockTypeEnhanced.h:

class clockTypeEnhanced

{

public:

      void elapsed ( int sec );

};

Add a comment
Know the answer?
Add Answer to:
C++ programining exercise 2. Do Chapter 10's Programming Exercise 8, using the name Lab12ClockType Enhanced. (Your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language is C++ Basic principles and theory of structured programming in C++ by implementing the class:...

    Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...

  • How do I format this into C++? This the prompt: Design a class named Password that...

    How do I format this into C++? This the prompt: Design a class named Password that stores a password in a c-string and has member functions to test if the password complies with certain requirements as follows: The password should be between 6 and 20 characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. The password should have at least one punctuation character. Define a...

  • So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file...

    So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file created and open in Dev C++. However, every time I try to compile I get a series of undefined reference to errors. Any advice is much appreciated!!! (45 pts) Work Programming Exercise 9.2 (class Fan) in the textbook on page 367. Additional specifications: • Use separate header and implementation files. • The main program (not the functions) should display the values of Speed, On,...

  • Construct a class named Room that declares two double-precision data members named length and width (2...

    Construct a class named Room that declares two double-precision data members named length and width (2 points). Include a constructor that initializes each data member to 1.0 when a Room object is created (1 point). Add two accessor functions for displaying the length and width values of a Room object and two mutator functions that allow changing these data member values. (2 points) Write a program that tests all functionality of this class. (3 points) Extra Credit: Create this class...

  • C++ Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add t...

    C++ Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add the function print to this class to output the radius, area, and circumference of a circle.) Now every cylinder has a base and height, where the base is a circle. Design a class cylinderType that can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class circleType designed in chapter 10.   Some of the...

  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

  • c++ programming language Instructions In this exercise, you will design the class memberType. Each object of...

    c++ programming language Instructions In this exercise, you will design the class memberType. Each object of memberType can hold the name of a person, member ID, number of books bought, and amount spent. Include the member functions to perform the various operations on the objects of memberType—for example, modify, set, and show a person’s name. Similarly, up-date, modify, and show the number of books bought and the amount spent. Add the appropriate constructors. Write the definitions of the member functions...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • 3. write a c++ program: Design and implement a class called Clock that describes the time...

    3. write a c++ program: Design and implement a class called Clock that describes the time of a clock: a) Include in the class 3 constructors with one, two, and three parameters to set the hours, the minutes, and the seconds, respectively. b) Include also a default constructor that sets the member variables of the class to 00:00:00. c) Write a member function to increment the time by a given amount, and second member function to reset the clock. The...

  • This is a standard C++ programming assignment using a command line g++ compiler or the embedded...

    This is a standard C++ programming assignment using a command line g++ compiler or the embedded one in zyBooks. No GUI forms and no Visual Studio. No external files and no databases are used. There is only one object-oriented program to complete in this assignment. All code should be saved in a file named ExamScoresUpdate.cpp, which is the only file to submit for grading. No .h files used. The .cpp file contains main() and two classes, ExamScores and DataCollector. There...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT