0% found this document useful (0 votes)
7 views

OOP-Report-on-Creating-a-program-that-functions-as-a-stopwatch-using-C-313305-Third-Micro-project-Msbte-Store_

Uploaded by

priyanshu10824
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

OOP-Report-on-Creating-a-program-that-functions-as-a-stopwatch-using-C-313305-Third-Micro-project-Msbte-Store_

Uploaded by

priyanshu10824
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Subject: Object Oriented Programming Using C++ (OOP)

Branch: CO, An and IF

Subject Code: 313305

Scheme: K-scheme

Academic Year: 2024-2028

A product by MSBTE STORE

Title - Report on Creating a program that functions as a stopwatch


Micro Project on Creating a program that functions as a stopwatch

1.0 Aims of the micro-project


The aims of the micro project, creating a stopwatch program in C++, include the following:

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.

3. Accuracy and Precision: The stopwatch program should leverage appropriate


libraries and functions to ensure accurate measurement of time. It should strive to
provide precise and reliable results when calculating the elapsed time.

4. Robustness: The program should handle different scenarios gracefully. It should


account for cases such as attempting to start or stop the stopwatch when it is
already in that state. It should also handle incorrect or invalid user commands,
providing clear feedback to the user.

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:

1. Understanding Programming Fundamentals: The project involves applying


fundamental programming concepts such as variables, control flow, user input
handling, and conditional statements. By completing the project, students gain a
better understanding of these core concepts and how to utilize them in practical
programming scenarios.

2. Developing Problem-Solving Skills: The project presents a problem to solve – creating


a stopwatch program with specific functionality. Students are required to analyze the
problem, break it down into smaller tasks, and implement solutions using
appropriate algorithms and code structures. This helps develop their problem-
solving skills and logical thinking abilities.

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.

5. Promoting Modularity and Reusability: The project encourages students to design


their code in a modular manner, allowing for future enhancements or integration
into larger applications. This fosters the development of reusable code components
and emphasizes the importance of designing software systems that are flexible and
adaptable.

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:

● Identify the functional requirements of the stopwatch program, such as


starting, stopping, and resetting the timer.

● Determine any additional features or constraints required by the project.

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.

● Decide on the user interface approach, whether it’s a command-line interface


or a graphical user interface (GUI).

● Determine the control flow, including how user input will be handled and
how the program will respond to different commands.

3. Development:

● Set up the C++ development environment.

● Implement the program according to the designed structure and logic.

● 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:

● Develop a comprehensive test plan to ensure the program functions as


intended.

● Test the program using various test cases, including starting, stopping, and
resetting the stopwatch in different scenarios.

● Verify the accuracy of time measurement and the program’s response to


different commands.

● 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.

● Include relevant information, such as the purpose of the program, its


features, and any limitations.

6. Iteration and Refinement:

● Review the code, documentation, and user feedback to identify areas for
improvement.

● Refactor the code to improve readability, efficiency, or maintainability, if


necessary.

● Update the documentation to reflect any changes made.

● 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

Sr. no. Name of resource material Specifications Quantity

Object Oriented Programming Using C+


1 textbook 1
+ (313305)

2 internet Wikipedia

3 PC windows 11 1

5.0 Brief Description:-


The project involves creating a stopwatch program in C++. The program aims to provide
a user-friendly interface where users can start, stop, and reset the timer. The stopwatch
program accurately measures and displays the elapsed time using the <chrono> library in C+
+.

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.

The project aims to address course outcomes related to programming fundamentals,


problem-solving skills, applying external resources (libraries), enhancing user interaction,
ensuring code quality, and promoting modularity and reusability.

By completing the project, students gain hands-on experience in implementing a practical


application using C++. They develop a better understanding of fundamental programming
concepts and practices, while also improving their problem-solving, code organization, and
user interaction skills.

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;

std::cout << "Stopwatch started." << std::endl;

else {

std::cout << "Stopwatch is already running." << std::endl;

}
}

void stop() {

if (running) {

stop_time = std::chrono::steady_clock::now();

running = false;

std::cout << "Stopwatch stopped." << std::endl;

else {

std::cout << "Stopwatch is not running." << std::endl;

void reset() {

if (!running) {

start_time = std::chrono::steady_clock::time_point();

stop_time = std::chrono::steady_clock::time_point();

std::cout << "Stopwatch reset." << std::endl;

else {

std::cout << "Stopwatch is running. Stop it first to reset." << std::endl;

void displayElapsedTime() {

if (!running && start_time != std::chrono::steady_clock::time_point()) {

std::chrono::duration<double> elapsed_seconds = stop_time - start_time;


std::cout << "Elapsed time: " << elapsed_seconds.count() << " seconds." << std::endl;

else if (running) {

std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now();

std::chrono::duration<double> elapsed_seconds = current_time - start_time;

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 {

std::cout << "Stopwatch Menu:\n";

std::cout << "1. Start\n";

std::cout << "2. Stop\n";

std::cout << "3. Reset\n";

std::cout << "4. Display Elapsed Time\n";

std::cout << "5. Exit\n";

std::cout << "Enter your choice: ";

std::cin >> choice;


switch (choice) {

case 1:

stopwatch.start();

break;

case 2:

stopwatch.stop();

break;

case 3:

stopwatch.reset();

break;

case 4:

stopwatch.displayElapsedTime();

break;

case 5:

std::cout << "Exiting the program." << std::endl;

break;

default:

std::cout << "Invalid choice. Please try again." << std::endl;

std::cout << std::endl;

std::this_thread::sleep_for(std::chrono::seconds(1));

} while (choice != 5);

return 0;

}
5.2 Output of Code-
6.0 Actual Resources Used
Sr. no. Name of resource material Specifications Quantity

Object Oriented Programming Using C+


1 textbook 1
+ (313305)

2 internet Wikipedia

3 PC windows 11 1

7.0 Outputs of the Micro-Projects


The outputs of the micro-project, creating a stopwatch program in C++, include the
following:

1. Stopwatch Program:

● The main output of the micro-project is the stopwatch program itself. It is a


fully functional program that can be compiled and executed in a C++
development environment.

● The stopwatch program provides the desired functionality, allowing users to


start, stop, and reset the timer.

● 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.

● Users are prompted to input commands (start/stop/reset) to control the


stopwatch.

● The program provides informative feedback or output, such as indicating


when the stopwatch is started, stopped, or reset.

3. Time Measurements:
● The stopwatch program accurately measures the elapsed time in seconds.

● It utilizes the <chrono> library to access high-resolution clocks for precise


time measurement.

4. Error Handling:

● The program incorporates error handling mechanisms to handle invalid user


input or actions.

● It provides appropriate error messages or feedback when users attempt to


perform actions that are not allowed or when commands are not recognized.

5. Documentation:

● The micro-project includes documentation that provides clear and concise


comments within the code.

● The documentation explains the purpose and functionality of the stopwatch


program, as well as any limitations or constraints.

● It may also include a user manual or guide that explains how to use the
stopwatch program effectively.

By completing the micro-project, the outputs mentioned above contribute to a


fully functional stopwatch program that meets the user requirements, provides accurate
time measurements, offers a user-friendly interface, and demonstrates robustness through
error handling.

8. 0 Skill Developed / Learning outcomes of this Micro-Project


a) Computer skills increase.

b) Communication skills improved.

9.0 Planning the Features


The first step in the methodology involves defining the key features of the stopwatch
program. These will be implemented using C++, a powerful and efficient language known for
its speed and control over system resources. The features to be included are:

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:

1. Time Tracking and Productivity Tools:

● 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.

● It can be incorporated into productivity tools or applications that aim to


improve time management and efficiency.

2. Sports and Fitness:

● The stopwatch program can be utilized in sports training or fitness activities


where precise timing is required, such as measuring sprint times, workout
durations, or rest intervals.

● It can be integrated into sports training apps or fitness trackers to provide


accurate time measurements during workouts.

3. Experiments and Research:

● The stopwatch program can be used in scientific experiments or research


studies that require precise timing and measurement of elapsed time.

● It can aid in conducting time-based experiments, tracking reaction times, or


measuring intervals between events.

4. Game Development:

● The stopwatch functionality can be utilized in game development for


implementing time-based game mechanics, such as timed challenges or
speedruns.

● It can be used to measure game session durations or track time-related


events within the game.
5. Simulations and Simulators:

● The stopwatch program can be incorporated into simulations or simulators


where accurate timing is crucial.

● It can be used to measure simulated time intervals, control time-based


events, or record simulation durations.

6. Educational Purposes:

● The stopwatch program can be employed as an educational tool to teach


programming concepts, such as variables, control flow, and user interaction.

● It can serve as a practical example to demonstrate the implementation of


basic functionalities in a programming language.

7. Cooking and Culinary Uses:

● In the kitchen, a stopwatch can be used for precise timing of cooking or


baking processes. Chefs can track cooking intervals to ensure meals are
prepared perfectly and at the right times.

8. Event Coordination:

● For organizers and participants in events like marathons, meetings, or


competitions, the stopwatch can help track specific timings and ensure that
events stay on schedule. Laps can be used to measure participant progress
during races or timed segments.

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.

The completion of the micro-project addressed several course outcomes, including


understanding programming fundamentals, problem-solving skills, applying external
resources (libraries), enhancing user interaction, ensuring code quality, and promoting
modularity and reusability.

Overall, the micro-project provided hands-on experience in implementing a practical


application using C++. It enhanced understanding of programming concepts, problem-
solving skills, and code organization. The stopwatch program has various potential
applications in domains such as time tracking, sports and fitness, experiments and research,
game development, simulations, and education.

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/

You might also like