0% found this document useful (0 votes)
25 views6 pages

SE Cons Assignment 1

Uploaded by

fu221135
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)
25 views6 pages

SE Cons Assignment 1

Uploaded by

fu221135
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/ 6

Islamia College Peshawar

www.icp.edu.pk

ASSIGNEMENT NO:-1

INTRODUCATION TO
SOFTWARE
CONSTRUCTION
Name:- Farman Ullah
Roll No:- 221135
BSSE Section (A)

Submitted by:
Farman Ullah

Submission Date:
05/12/2024
Currency Converter Documentation

Overview

The Currency Converter program allows users to convert an amount from one currency to
another. It provides a graphical user interface (GUI) where users can select the source
currency, target currency, and enter an amount. Once the user clicks the "Convert" button, the
program calculates the converted amount and displays the result.

Features

 Currency Selection: The user can choose the source and target currencies from a
dropdown list.
 Amount Input: The user can enter the amount to be converted.
 Conversion Calculation: The program converts the entered amount from the source
currency to the target currency using predefined conversion rates.
 Error Handling: If the user enters an invalid amount or if no amount is entered, the
program will display an error message.
 Result Display: The converted amount is displayed in a non-editable field with the
appropriate currency symbol.
Technologies Used

 Java Swing: The program uses Java Swing for creating the graphical user interface
(GUI). Swing provides a set of lightweight components to build rich user interfaces.
 GridBagLayout: The layout manager used for organizing the components in the GUI
for a flexible and professional design.
 Event Handling: Action listeners are used to handle user interactions, such as
clicking the "Convert" button.
 Basic Java I/O: To handle input and output (amounts and conversion results).

Classes and Methods

CurrencyConverter Class

This is the main class of the application. It sets up the GUI and handles user interactions.

Constructor:

 CurrencyConverter(): Initializes the GUI by setting up the window and components


such as labels, text fields, combo boxes, and the convert button.

Method:

 initializeUI(): Sets up the user interface components, including layout, color


scheme, and positioning of components.
 convertCurrency(double amount, String sourceCurrency, String
targetCurrency): Performs the currency conversion based on predefined exchange
rates. Returns the converted amount.
 main(String[] args): Launches the application by invoking the constructor on the
Swing event dispatch thread.

ConvertButtonListener Class

This is an inner class that implements the ActionListener interface. It is responsible for
handling the "Convert" button click event.

Method:

 actionPerformed(ActionEvent e): This method is invoked when the user clicks


the "Convert" button. It retrieves the input amount, performs validation, and updates
the result field with the converted amount.

GUI Components

1. JFrame: The main window of the application.


2. JTextField: Used for entering the amount to be converted and displaying the result.
3. JComboBox: Dropdown menu to select the source and target currencies.
4. JLabel: Displays text for each input field (amount, source currency, target currency,
and result).
5. JButton: The button that triggers the conversion.
6. JOptionPane: Used to display error messages if the user enters invalid input or
leaves a field empty.

Currency Conversion Logic

The currency conversion is done based on predefined rates for different currency pairs.
Below is an overview of the conversion logic:

 USD to EUR: Conversion rate of 0.85


 USD to GBP: Conversion rate of 0.75
 USD to INR: Conversion rate of 74.50
 USD to PKR: Conversion rate of 287.50
 USD to SAR: Conversion rate of 3.75
 EUR to USD: Conversion rate of 1.18

Additional currency pairs can be added in the convertCurrency method with appropriate
conversion rates.

Design and User Interface

The program features a modern, clean, and professional user interface inspired by banking
applications, with the following design elements:

 Background Color: A dark blue color (#1E2A47) is used to give the application a
professional, banking-like feel.
 Button Color: The "Convert" button is styled with a green background (#4CAF50),
making it stand out as an action button.
 Input Fields: The fields for entering the amount and displaying the result have a light
blue background (#D6E4F0) to visually differentiate them from other components.
 Font: Arial font is used for text fields and labels to provide a clean, professional look.

 If the user enters an invalid amount (non-numeric input), a pop-up error message is
displayed, prompting the user to enter a valid number.
 If the amount field is left empty, an error message appears asking the user to enter
an amount before proceeding with the conversion.

Example Use Case

1. Launching the Application: When the program is run, a window opens with fields to
enter the amount, select the source and target currencies, and display the result.
2. Performing Conversion:
o The user selects "USD" as the source currency and "EUR" as the target
currency.
o The user enters "100" as the amount to be converted.
o After clicking the "Convert" button, the program calculates the converted
amount (100 USD to EUR), displaying the result (85 EUR) in the result field.
Limitations

 The program uses static conversion rates for simplicity. In a real-world application,
the rates should be fetched from an API to ensure they are up-to-date.
 Only a small set of currencies are supported. More currencies can be added by
extending the convertCurrency method.

Future Improvements

 Dynamic Exchange Rates: Integrating an external API (such as the ExchangeRate-


API) to fetch live exchange rates.
 Support for More Currencies: Adding support for more currencies by updating the
conversion rates and extending the currency selection options.
 Error Handling Improvements: Better handling of edge cases, such as large input
amounts or currency pairs not available in the current setup.

 Enhanced UI/UX: Further improvements to the design, such as adding icons for
currencies or using a more sophisticated layout manager for better component
responsiveness.

1st Code screenshot

2nd screenshot of code


3rd Screenshot of Code

4th Screenshot of Code

You might also like