OOP-Report-on-Creating-a-program-that-functions-as-a-stopwatch-using-C-313305-Third-Micro-project-Msbte-Store_
OOP-Report-on-Creating-a-program-that-functions-as-a-stopwatch-using-C-313305-Third-Micro-project-Msbte-Store_
Scheme: K-scheme
1. Stopwatch Functionality: The primary aim is to develop a program that emulates the
functionality of a stopwatch. Users should be able to start, stop, and reset the timer
as needed. The stopwatch program should accurately measure and display the
elapsed time.
2. User Interaction: The program should provide a user-friendly interface where users
can input commands to control the stopwatch. It should prompt the user for
commands, handle user input, and provide appropriate feedback or error messages
when necessary.
5. Code Efficiency and Readability: While the project may be relatively small, it is
important to aim for code that is efficient, organized, and follows best practices. This
includes using appropriate variable names, commenting code sections where
necessary, and structuring the code in a way that is easy to understand and
maintain.
By achieving these aims, the micro project will result in a functional stopwatch program that
meets user requirements, is reliable and accurate, and provides a solid foundation for
further development or integration into larger applications.
2.0 Course outcome addressed.
The micro project of creating a stopwatch program in C++ addresses the following course
outcomes:
3. Applying Libraries and External Resources: The project involves utilizing the
<chrono> library in C++ to work with time-related functions and data types. By
incorporating external resources like libraries into their project, students learn how
to leverage existing tools to enhance their programs and improve efficiency.
4. Ensuring Code Quality and Readability: Through the project, students are
encouraged to write clean, well-organized, and readable code. They learn the
importance of using appropriate variable names, adding comments for clarity,
following coding conventions, and maintaining code efficiency. These practices
contribute to producing high-quality code that is easier to understand and maintain.
By addressing these course outcomes, the micro project not only helps students reinforce
their understanding of programming concepts but also equips them with practical skills that
can be applied to more complex programming tasks in the future.
3.0 Proposed methodology
The proposed methodology for creating a stopwatch program in C++ includes the following
steps:
1. Requirement Analysis:
2. Design:
● Plan the overall structure of the program, considering the variables, user
interface, and control flow.
● Define the necessary variables to store timestamps and track the stopwatch
state.
● Determine the control flow, including how user input will be handled and
how the program will respond to different commands.
3. Development:
● Use the appropriate time-related functions and data types from the <chrono>
library for accurate time measurement.
● Write code to handle user input, perform necessary calculations, and display
appropriate feedback or output.
4. Testing:
● Test the program using various test cases, including starting, stopping, and
resetting the stopwatch in different scenarios.
● Fix any bugs or issues identified during testing and retest the program.
5. Documentation:
● Document the program by providing clear and concise comments within the
code.
● Create a user manual or guide explaining how to use the stopwatch program.
● Review the code, documentation, and user feedback to identify areas for
improvement.
● Repeat the testing process to ensure the modifications did not introduce new
issues.
Throughout the entire process, it is important to follow coding best practices, adhere to
coding standards, and regularly seek feedback from peers or mentors to ensure the
successful completion of the stopwatch program in C++.
4.0 Resources used
2 internet Wikipedia
3 PC windows 11 1
The program utilizes basic programming concepts such as variables, control flow, and user
input handling. It prompts the user for commands and executes the corresponding actions
based on the user’s input. The program tracks the start time and end time of the stopwatch
and calculates the elapsed time by subtracting the start time from the end time.
To enhance user interaction, the program provides appropriate feedback messages to the
user, such as indicating when the stopwatch is started, stopped, or reset. It also handles
scenarios where the user attempts to start or stop the stopwatch when it is already in that
state.
Throughout the project, emphasis is placed on code quality, readability, and modularity.
Clean and well-organized code is employed, following coding conventions and utilizing
meaningful variable names. Additionally, the program is designed to be modular, allowing
for future enhancements or integration into larger applications.
5.1 Code-
#include <iostream>
#include <chrono>
#include <thread>
class Stopwatch {
private:
std::chrono::steady_clock::time_point start_time;
std::chrono::steady_clock::time_point stop_time;
bool running;
public:
Stopwatch() : running(false) {}
void start() {
if (!running) {
start_time = std::chrono::steady_clock::now();
running = true;
else {
}
}
void stop() {
if (running) {
stop_time = std::chrono::steady_clock::now();
running = false;
else {
void reset() {
if (!running) {
start_time = std::chrono::steady_clock::time_point();
stop_time = std::chrono::steady_clock::time_point();
else {
void displayElapsedTime() {
else if (running) {
std::cout << "Running time: " << elapsed_seconds.count() << " seconds." << std::endl;
else {
std::cout << "Stopwatch has not been started or reset." << std::endl;
};
int main() {
Stopwatch stopwatch;
int choice;
do {
case 1:
stopwatch.start();
break;
case 2:
stopwatch.stop();
break;
case 3:
stopwatch.reset();
break;
case 4:
stopwatch.displayElapsedTime();
break;
case 5:
break;
default:
std::this_thread::sleep_for(std::chrono::seconds(1));
return 0;
}
5.2 Output of Code-
6.0 Actual Resources Used
Sr. no. Name of resource material Specifications Quantity
2 internet Wikipedia
3 PC windows 11 1
1. Stopwatch Program:
● It accurately measures and displays the elapsed time using the appropriate
time-related functions and data types from the <chrono> library.
2. User Interface:
● The program presents a user-friendly interface where users can interact with
the stopwatch.
3. Time Measurements:
● The stopwatch program accurately measures the elapsed time in seconds.
4. Error Handling:
5. Documentation:
● It may also include a user manual or guide that explains how to use the
stopwatch program effectively.
1. Start/Stop Functionality: The program will utilize std::chrono from the C++ Standard
Library to track the time elapsed. The user will be able to start the stopwatch by invoking a
start command, which will record the current system time, and stop it, displaying the total
elapsed time.
2. Pause/Resume: The stopwatch should allow the user to pause time tracking without
resetting the recorded time. This can be achieved by storing the time when the pause
command is issued and calculating the elapsed time upon resumption by subtracting the
paused time from the total duration.
3. Lap Tracking: The program will allow the user to record lap times, storing the time at
which each lap occurs. This will be done by capturing the current time when the user hits
the lap button and saving it in a vector for future reference, providing a clear breakdown of
individual lap durations.
4. Reset: The stopwatch will include a reset feature, which will clear all previously recorded
times and return the stopwatch to its initial state, ready for a new session. This feature
ensures that the program can be reused multiple times efficiently.
10.0 Applications of this Micro-Project
The micro-project of creating a stopwatch program in C++ has various applications in
different domains. Some potential applications of this micro-project include:
● The stopwatch program can be used as a basic time tracking tool for
individuals to monitor and measure the time spent on specific tasks or
activities.
4. Game Development:
6. Educational Purposes:
8. Event Coordination:
These are just a few potential applications of the stopwatch program. The versatility and
flexibility of the micro-project allow it to be adapted and integrated into various domains
where precise time measurement and tracking are required.
11.0Project Objectives
The primary objective of this project is to create a stopwatch program using C++ that allows
users to accurately track time. The stopwatch will provide basic functionalities such as
starting, stopping, and resetting the timer. These core functions will be implemented using
the std::chrono library, which allows precise time tracking. The stopwatch is intended to be
simple, intuitive, and efficient, ensuring that users can measure elapsed time reliably
without any performance lag.
A secondary objective is to ensure the stopwatch provides flexibility through a reset feature.
Users will be able to clear the current time and reset the stopwatch back to zero, allowing it
to be used multiple times within a single session. The reset function will effectively clear any
recorded time and start a fresh time count when restarted. This ensures that users do not
need to close and reopen the program to reuse it, improving the overall user experience.
Lastly, the project aims to develop a program that can be easily expanded in the future. The
structure of the code will be designed with flexibility in mind, so that additional features,
such as lap timing, pause/resume functionality, or exporting time records to external files,
can be added later if needed. This will allow the stopwatch to evolve beyond basic
functionality, making it useful in more specialized applications, such as sports timing,
software performance measurement, or even industrial processes where precise time
intervals need to be monitored.
Conclusion
In conclusion, the micro-project of creating a stopwatch program in C++ has been
successfully completed. The project aimed to develop a program that emulates the
functionality of a stopwatch, allowing users to start, stop, and reset the timer. The program
accurately measured and displayed the elapsed time using the <chrono> library in C++.
Throughout the project, key objectives were achieved. The program provided a user-friendly
interface where users could input commands to control the stopwatch. It responded to user
input, performed the necessary calculations, and provided appropriate feedback or error
messages. The program incorporated error handling mechanisms to handle invalid
commands and scenarios gracefully.
The stopwatch program demonstrated accuracy and precision in measuring time intervals. It
utilized the <chrono> library to access high-resolution clocks, ensuring reliable and accurate
time measurements. The program was robust, handling different scenarios such as
attempting to start or stop the stopwatch when it is already in that state.
Code quality and readability were prioritized in the project. The code was structured in a
modular manner, promoting reusability and potential future enhancements. Best coding
practices were followed, including the use of meaningful variable names and appropriate
comments.
Through the successful completion of the micro-project, valuable knowledge and skills
were gained, contributing to the growth and development of programming abilities.
Reference
1. https://msbtestore.com/
2. https://www.wikipedia.org/
3. https://www.google.com/