Professional Documents
Culture Documents
1.INTRODUCTIO
1.1 Background:
In today's digital age, calculators are ubiquitous tools used for performing arithmetic
calculations quickly and accurately. With the widespread adoption of computers and
mobile devices, there is a demand for digital calculators that provide not only basic
arithmetic functions but also additional features and a user-friendly interface.
The motivation behind this project is to develop a modern and versatile calculator
application that meets the needs of users across various platforms. Whether it's students
solving math problems, professionals calculating finances, or individuals performing
everyday calculations, a well-designed calculator can streamline these tasks and
enhance productivity.
1.2 Objectives:
The primary objectives of the project are as follows:
1|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
2.Project Overview
The project involves the development of a modern and versatile calculator application
that aims to provide users with a comprehensive set of features and functionalities for
performing arithmetic calculations efficiently. The calculator is designed to be user-
friendly, intuitive, and capable of handling a wide range of mathematical tasks.
Scope:
The scope of the project includes:
• Designing and implementing a graphical user interface (GUI) for the calculator
application using Java Swing.
• Developing algorithms and logic to perform basic arithmetic operations such as
addition, subtraction, multiplication, and division.
• Implementing additional features such as exponentiation, square root,
percentage calculation, and memory functions to enhance the calculator's utility.
• Ensuring accurate calculation results and proper error handling to maintain the
reliability and integrity of the calculator.
• Supporting cross-platform compatibility to make the calculator accessible on
various devices and operating systems.
2|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
4. Cross-Platform Compatibility:
• Compatibility with different devices and operating systems, including
Windows, macOS, and Linux.
• Responsive design for optimal performance on desktop and mobile
devices.
3|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
3. Technologies Used
1. Programming Language: Java
• Java was chosen for its platform independence, robustness, and suitability
for developing desktop applications.
2. GUI Library: Java Swing
• Java Swing was utilized to create the graphical user interface (GUI) for
the calculator application.
• Swing provides a set of components and utilities for building desktop
applications in Java.
3. Integrated Development Environment (IDE): IntelliJ IDEA, Eclipse, or
NetBeans
• An IDE such as IntelliJ IDEA, Eclipse, or NetBeans was used for writing,
editing, compiling, and debugging Java code.
• IDEs offer features like syntax highlighting, code completion, and
debugging tools that enhance the development process.
4. Version Control: Git
• Git was used for version control to track changes made to the project's
source code.
• Git enables collaboration, code sharing, and version management among
team members.
5. Documentation: Markdown
• Markdown was used for writing project documentation, including this
report.
• Markdown is a lightweight markup language that allows for easy
formatting of text documents.
6. Testing Framework: JUnit (optional)
• JUnit could be used for writing and running automated tests to verify the
correctness of the calculator application's logic and functionalities.
• Automated testing helps ensure the reliability and quality of the software.
7. Build Tool: Apache Maven or Gradle (optional)
• Apache Maven or Gradle could be used as build automation tools to
manage project dependencies, compile source code, and package the
application.
• Build tools simplify the build process and help maintain project
consistency.
8. Graphics Editing Tool: Adobe Photoshop, GIMP, or similar (optional)
• Graphics editing tools like Adobe Photoshop or GIMP could be used for
designing custom graphics or icons for the calculator's user interface.
4|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
5|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
4. Architecture
4.1 Architecture:
The overall architecture of the project follows a Model-View-Controller (MVC) design
pattern, which separates the application into three main components:
1. Model: The model represents the application's data and business logic. In this
project, the model consists of classes responsible for performing arithmetic
calculations, handling user input, and managing memory operations.
2. View: The view represents the user interface (UI) of the application. It
includes components such as buttons, text fields, and labels that allow users to
interact with the calculator. In this project, the view is implemented using Java
Swing components, providing a graphical interface for input and output.
3. Controller: The controller acts as an intermediary between the model and the
view. It handles user input events, delegates tasks to the model for processing,
and updates the view with the results. In this project, the controller is
implemented as event listeners attached to UI components, such as buttons, to
respond to user actions.
The MVC architecture promotes separation of concerns and modularity, making the
codebase easier to understand, maintain, and extend. It also facilitates code reuse and
testing by decoupling the UI from the underlying logic.
1. Input Area: A text field or display area where users can input numbers and
view calculation results.
2. Numeric Buttons: Buttons labeled with numbers (0-9) that allow users to
input numerical values.
3. Operation Buttons: Buttons labeled with arithmetic operations (+, -, *, /) and
additional functions (exponentiation, square root, percentage, memory) that
enable users to perform calculations.
4. Clear and Equals Buttons: Special buttons for clearing the input field (C) and
executing the calculation (=).
5. Layout and Styling: The UI is organized and styled to enhance readability
and usability. Components are arranged logically, with proper spacing and
alignment to improve visual clarity.
6|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
7|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
5. Implementation
5.1 Features
Main Features and Functionalities:
1. Main Class (GUI_Calculator.java): This class serves as the entry point of the
application and contains the main program logic, including the creation of the
GUI and event handling.
2. Controller: Event listeners are implemented as inner classes within the main
class to handle user interactions with the GUI components, such as button clicks.
3. Model: The model consists of classes responsible for performing arithmetic
calculations, handling user input, and managing memory operations. These
classes encapsulate the application's data and business logic.
4. View: The view component is represented by the GUI elements created using
Java Swing, including buttons, text fields, and labels.
8|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
5.3 Algorithms
Logic and Algorithms Used:
9|Page
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
6. Testing
• Unit Testing: All unit tests passed successfully without any failures.
• Integration Testing: Integration tests confirmed that components
interacted correctly and produced the expected outcomes.
• Functional Testing: The calculator application successfully performed all
arithmetic operations and additional functions as specified.
• User Acceptance Testing (UAT): End-users found the application easy to
use and reported no significant issues or bugs.
10 | P a g e
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
7. Deployment
1. Build: The project was compiled into an executable JAR file using the build
tool (e.g., Apache Maven or Gradle).
2. Testing: The JAR file was tested in a staging environment to ensure it
functions correctly and meets quality standards.
3. Packaging: The JAR file, along with any necessary resources (e.g., icons,
configuration files), was packaged into a deployable artifact.
4. Distribution: The artifact was distributed to end-users via various channels,
such as direct download from a website or distribution through app stores.
5. Installation: End-users installed the application on their devices following
standard installation procedures.
11 | P a g e
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
8.Future Work
12 | P a g e
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
9. Code
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public GUI_Calculator()
{
currentInput = ""; // Initialize currentInput
// Initialize components
displayField = new JTextField();
displayField.setEditable(false);
add(displayField, BorderLayout.NORTH);
add(buttonPanel, BorderLayout.CENTER);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
JButton source = (JButton) e.getSource();
String buttonText = source.getText();
if (buttonText.equals("="))
{
calculate();
} else if (buttonText.equals("C"))
{
clear();
} else if (buttonText.matches("[0-9]"))
{
currentInput += buttonText;
displayField.setText(currentInput);
} else
{
currentOperation = buttonText;
currentInput += " " + currentOperation + " ";
displayField.setText(currentInput);
}
14 | P a g e
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
switch (currentOperation)
{
case "+":
result = num1 + num2;
break;
case "-":
result = num1 - num2;
break;
case "*":
result = num1 * num2;
break;
case "/":
if (num2 != 0)
result = num1 / num2;
else {
displayField.setText("Error: Division by zero");
return;
}
break;
}
displayField.setText(String.valueOf(result));
currentInput = String.valueOf(result);
}
11.Output
16 | P a g e
YASHWANTRAO BHONSALE INSTITUTE OF TECHNOLOGY
12.Conclusion
The Java GUI Calculator project successfully developed a feature-rich calculator
application with an intuitive user interface. The project achieved its objectives of
providing users with a reliable tool for performing arithmetic calculations
efficiently. Key findings and achievements include:
13.References
https://chat.openai.com/c/9ac35712-d060-494a-aacd-9259763787a4
https://evidhya.com/subjects/java/applet-simple-calculator
https://gist.github.com/GursimranSingh95/7eec62b71111130d9a33b36d981b51d2
17 | P a g e