Project Khushhal
Project Khushhal
on
Session 2023-24
Under The Supervision of
Submitted By
Anas Khan(23SCSE1040379)
Khushhal Kumar(23SCSE1040363)
Granth Shandilya(23SCSE1040357)
Ashish Kashyap(23SCSE1040344)
Interest Calculator in C++ ” in partial fulfillment of the requirements for the award of the BCA
submitted in the School of Computing Science and Engineering of Galgotias University, Greater Noida, is an
original work carried out during the period of March, 2024 to June and 2024, under the supervision of Dr.
Lalit Kumar, School of Computer Applications and Technology, Galgotias University,Greater Noida
The matter presented in the thesis/project/dissertation has not been submitted by us for the award of any
This is to certify that the above statement made by the candidates is correct to the best of my knowledge.
Dr.Lalit Kumar
(Associate Professor)
CERTIFICATE
And his/her work is recommended for the award of Bachelor of Computer Applications.
Date:
Place:Greater Noida
ABSTRACT
Initialize two float variables num1 and num2 to take two operands as input.
Initialize a char variable op to take the operator as input.
Start the switch statement with op as the expression of the switch statement.
Now, create cases for different arithmetic operations.
CONTENT
LIST OF FIGURES
LIST OF TABLES
LIST OF ABBREVIATIONS
1 INTRODUCTION
1.1
1.2
2 LITERATURE REVIEW
2.1
2.2
3 EXISTING METHODOLOGY
3.1
3.2
4 PROPOSED METHODOLOGY
4.1
4.2
5 RESULTS
5.1
5.1.1
4.1
4.2.4.
LIST OF TABLES
5.1
5.2
LIST OF ABBREVATIONS
CHAPTER- 1
INTRODUCTION
Initialize two float variables num1 and num2 to take two operands as input.
Initialize a char variable op to take the operator as input.
Start the switch statement with op as the expression of the switch statement.
Now, create cases for different arithmetic operations.
CHAPTER-2
LITERATURE REVIEW
**Literature Review:**
A simple calculator program in C++ can be used to perform basic arithmetic operations such
as addition, subtraction, multiplication, and division. It can take input from the user, perform
the requested operation, and then display the result. This type of program is often used as a
learning exercise for beginners to understand concepts like variables, user input, conditional
statements, and basic arithmetic operations in programming. Additionally, it can serve as a
handy tool for quick calculations when needed.
```cpp
int main() {
char op;
float num1, num2, result;
```
Declare variables to store the operator (`op`), two numbers (`num1` and `num2`), and the
result of the calculation (`result`).
return 0;
}
```
Output the result of the calculation using `cout`.
```cpp
#include <iostream>
int main() {
char op;
float num1, num2, result;
switch(op) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
if(num2 != 0)
result = num1 / num2;
else {
cout << "Error! Division by zero is not allowed.";
return -1;
}
break;
default:
cout << "Error! Invalid operator.";
return -1;
}
return 0;
}
```
This program will perform basic arithmetic operations based on the user's input and
display the result.*Object-Oriented Design Patterns:*
CHAPTER-3
EXISTING METHODOLOGY
The existing methodology for a simple calculator typically involves the following steps:
1. User Interface: Provide a user interface where users can input numbers and select operations.
2. Input Handling: Capture user input for numbers and the desired operation.
3. Operation Execution: Based on the selected operation, perform the corresponding arithmetic
calculation.
1. User Interface
The user interface should be intuitive and allow users to:
This can be implemented using text-based interfaces (command-line interface) or graphical user
interfaces (using libraries like Qt, GTK, or Windows Forms).
2. Input Handling
Capture user input for:
Ensure input validation to handle cases where users enter invalid characters or divide by zero.
3. Operation Execution
Perform the arithmetic operation selected by the user:
• Print the result to the console or display it in the graphical user interface.
*pseudocode
Switch operation:
Case '+':
result = num1 + num2
Case '-':
result = num1 - num2
Case '*':
result = num1 * num2
Case '/':
if num2 != 0:
result = num1 / num2
else:
Display "Error: Division by zero"
Terminate program
Default:
Display "Error: Invalid operation"
Terminate program
CHAPTER-4
PROPOSED METHODOLOGY
1. Define the Operations: Decide which operations your calculator will support. Typically, it
includes addition, subtraction, multiplication, and division.
2. Design the User Interface: Determine how users will interact with your calculator. You might use
the console for input and output in a simple implementation.
3. Error Handling: Handle cases where the user enters invalid input (e.g., non-numeric input).
4. Testing: Test your calculator with various inputs to ensure it produces correct results and handles
errors gracefully.
CHAPTER 5: RESULT
#include <iostream>
int main() {
char op;
double num1, num2;
return 0;
}
OUTPUT :
CHAPTER 6:RESULTS AND DISCUSSION
Result: The implemented calculator allows users to perform basic arithmetic operations such as
addition, subtraction, multiplication, and division. It takes two numbers and an operator as input from
the user, performs the operation, and displays the result. The program also handles division by zero
error gracefully by providing an error message.
Discussion:
1. Functionality: The calculator performs basic arithmetic operations accurately. Users can easily
input numbers and select the desired operation.
2. User Experience: The user experience is straightforward as the program prompts the user for
input and displays the result. However, the console interface might not be the most user-friendly
for some users. Consider implementing a graphical user interface (GUI) for better usability.
3. Error Handling: The program handles division by zero error by displaying an error message.
However, it terminates after displaying the error message. You might want to allow users to
continue using the calculator after encountering an error.
CHAPTER 7
Conclusion:
The simple calculator implemented in C++ provides a basic yet functional tool for performing arithmetic
operations. It successfully allows users to input two numbers and select an operation to perform,
displaying the result accurately. The calculator demonstrates fundamental programming concepts such
as functions, user input handling, error checking, and basic arithmetic operations.
Future Work:
1. Graphical User Interface (GUI): Enhance the user experience by implementing a GUI using
libraries like Qt or GTK. A GUI would provide a more intuitive and user-friendly interface
compared to the console.
2. Input Validation: Improve robustness by implementing input validation to ensure that users
enter valid numeric input and a valid operator. This prevents unexpected behavior and enhances
error handling.
5. Memory Functions: Add memory functions like memory recall and memory clear to allow users
to store and retrieve values for further calculations.
7. Optimization: Optimize the code for efficiency and performance, especially for large
calculations. This may involve using more efficient algorithms or data structures.
8. Error Handling Improvement: Enhance error handling to provide more informative error
messages and allow users to recover from errors gracefully without terminating the program.
By implementing these enhancements and addressing areas for improvement, the simple calculator can
evolve into a more versatile, user-friendly, and feature-rich tool for performing mathematical
calculations in C++.
RFERENCES
4. GitHub Repositories:
• Explore GitHub repositories that contain simple calculator implementations in C++. Searching for
keywords like "simple calculator C++" on GitHub can lead you to various open-source projects and
code examples.
5. Educational Websites:
When using online resources, ensure to check the credibility and relevance of the information provided.
Additionally, referring to official C++ documentation (www.cppreference.com) can help you understand language
features and standard library functions used in your calculator implementation.