Question
C++ Program 2.1 - Class You will need to make a class named stopwatch with the attributes hour, minute, and second. You need to declare
C++ Program
2.1 - Class
You will need to make a class named stopwatch with the attributes hour, minute, and second. You need to declare them as private members. Your class will need to contain two constructors, a default that will set the classes attributes to 0, and a constructor that takes three arguments to set hour, minute and second.
2.2 - Main Program
Your main program should ask the user how many times they wish to enter and then create a dynamic array based on that input. The user should then be asked to enter the data for the time objects that will be stored in the array. If the user enters a value outside of the ranges for one or more of the attributes (i.e., negative for hours, negative or >60 values for minutes or seconds), the default constructor should be called. Once the array has been completed, the user should be presented with a menu with three options: 1) Print the Individual Stored Times, 2) Print the Total Time, 3) Exit the Program. In order to perform the first two menu functions you may need to expand your class beyond the earlier mentioned constructors. Specifically, to implement 1), add a new member function, called print_time() to print out the time in the format of hh:mm:ss (see the following example output for a demonstration). To implement 2), you need to implement a loop to go over all objects in your dynamic array and sum their times together. Remember, the range for minutes and seconds is both from 0 to 59. You need to properly carry the over-range value to hours or minutes if they are more than 60. You will need to format your program so that it matches the example output exactly. Do not change menu option numbers or add any additional input lines. As we are on the server you will not need to include system pause or the cin.ignore()/cin.getline() combo to pause the program. You will need to use the string type variable with cin to capture input and cout to print your 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