lOMoARcPSD|36985876
19BCG1020- Rajesh Kumar Behera(JAVA Project)
Software Engineering (Chandigarh University)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by Sakthi Kesavan (
[email protected])
lOMoARcPSD|36985876
CURRENCY CONVERTER
A Project Work Report
Submitted in the partial fulfilment for the award of the degree of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE & ENGINEERING
GRAPHIC & GAMING
Submitted by:
RAJESH KUMAR BEHERA
19BCG1020
Under the Supervision of:
Dr. Durgesh Srivastava
CHANDIGARH UNIVERSITY, GHARUAN, MOHALI - 140413, PUNJAB
December, 2020
Rajesh Kumar Behera
Name and signature of student(s)
Name and signature of Supervisor
lOMoARcPSD|36985876
PROJECT COMPLETION CERTIFICATE
Currency converter
This is to certify that I RAJESH KUMAR BEHERA has successfully completed
the project work titled “Currency Converter” Submitted in the partial fulfilment
for the award of the degree of BACHELOR OF ENGINEERING IN
COMPUTER SCIENCE AND ENGINEERING(GRAPHIC & GAMING).
This project is the record of authentic work carried out during the academic year
Dr. Durgesh Srivastava
Project Guide
Date: 08-12-2020
lOMoARcPSD|36985876
DECLARATION
I “RAJESH KUMAR BEHERA” hereby declare that the project report is based
on my own work carried out during the course of our study under the supervision of
Dr. Durgesh Srivastava. I assert the statements made and conclusions drawn are
an outcome of my work. I further certify that the work contained in the report is
original and has been done by me under the general supervision of my supervisor.
The work has not been submitted to any other Institution for any other
degree/diploma/certificate in this university or any other University of India or
abroad. We have followed the guidelines provided by the university in writing the
report. Whenever we have used materials (data, theoretical analysis, and text) from
other sources, we have given due credit to them in the text of the report and giving
their details in the references.
RAJESH KUMAR BEHERA
(19BCG1020)
lOMoARcPSD|36985876
ACKNOWLEDGEMENT
I have taken efforts in this project. However, it would not have been
possible without the kind support and help of many individuals and
organizations. I would like to extend my sincere thanks to all of them.
I am highly indebted to Dr. Durgesh Srivastava for their guidance and
constant supervision as well as for providing necessary information
regarding the project & also for their support in completing the project.
I would like to express my gratitude towards my parents and my
department for their kind co-operation and encouragement which help
me in completion of this project.
THANKS AGAIN TO ALL WHO HELPED
lOMoARcPSD|36985876
INDEX-
Chapter 1: Abstract
Chapter 2: Introduction to project
Chapter 3: Project Requirements (Software/Hardware requirements)
Chapter 4: Implementation Details (Algorithm, code )
Chapter 5: Output Analysis (screenshots)
lOMoARcPSD|36985876
ABSTRACT
Various nations utilize distinctive money, and there is every day variety in these
monetary standards comparatives with each other. The individuals who move cash
starting with one nation then onto the next (one money to another) must be
refreshed with the most recent money trade rates on the lookout.
Cash converter small scale venture is assembled remembering this thing. It is just
an adding machine-like application created utilizing Ajax, Java servlets web
highlights. In this application, there is customary update about cash of each nation
by which it shows present money market worth and change rate.
Such application can be utilized by any client, yet it is for the most part helpful for
business, offers, and account related regions where cash move and money trade
happens consistently.
In this money converter application, clients are given a choice to choose the sort of
transformation, for example from "this" money to "that" cash. This basic
component permits clients to enter sum to be changed over (state cash in Dollars),
and show the changed over sum (say money in Euro).
lOMoARcPSD|36985876
INTRODUCTION
CURRENCY CONVERTER
A cash converter is programming code that is intended to change one money into
another all together over to check its relating esteem. The code is commonly a piece
of a site or it frames a portable application and it depends on current market or bank
trade rates.
To change over one cash into another, a client enters a measure of cash (for
example '1000') and picks the cash he/she wishes to check the money related
estimation of (for example 'US Dollar'). From that point forward, the client chooses
one, or some of the time a few different monetary forms, he/she might want to see
the outcome in. The application programming at that point computes and shows the
comparing measure of cash.
Money converters expect to keep up continuous data on current market or bank
trade rates, so the determined outcome changes at whatever point the estimation of
both of the segment monetary standards does. They do as such by interfacing with
an information base of current cash trade rates. The recurrence at which cash
converters update the trade rates they use differs: Yahoo cash converter refreshes its
rates each day, while Convert My Money< consistently.
Money converters typically show a worth that isn't one-sided towards purchasing or
selling. This is helpful when:
Assessing the estimation of merchandise or administrations
Essential bookkeeping and invoicing
Planning monetary plans and reports
The money change programming ascertains the rates as decimal point numbers with
ordinarily 4 decimals after the comma. Some may ascertain the transformation rates
with more decimals inside yet just 4 are shown. This is identified with exactness,
programming disguise (i18n) and how the global business sectors work, where
most changes have 4 decimal spots, albeit some money matches additionally have
5. Most money converters utilize around 4.
lOMoARcPSD|36985876
A money transformation expense is a charge required by the credit or check card
instalment processor or ATM organization to change one cash over to another as a
component of a monetary exchange.
An unfamiliar exchange expense is a charge required by your credit or check card
guarantor or ATM network on a similar exchange. The unfamiliar exchange
expense may incorporate the cash change charge, contingent upon whether the card
guarantor or ATM network gives that expense to you. (A few cards don't charge
unfamiliar exchange expenses.)
Dynamic cash change (DCC) is normally more expensive than money
transformation through the Visa processor, yet it lets you see the expense of your
exchange in U.S. dollars when you cause it instead of when you to get your Visa
bill.
lOMoARcPSD|36985876
REQUIREMENTS
SOFTWARE REQUIREMENT-
JAVA (Eclipse IDE – 64 Bit)
HARDWARE REQUIREMENTS-
Processor – Intel Pentium and more
Motherboard- Intel Chipset Motherboard
RAM- 128MB and more
Cache- 512 KB
Hard Disk- 16GB hard disk recommended
lOMoARcPSD|36985876
PROCEDURE FOR CONVERSION
(ALGORITHM)
getCurrency() : java.util.Currency.getCurrency() method returns ISO 4217
currency code of the passed currency argument.
getInstance() : java.util.Currency.getInstance() method creates currency instance
for Currency code.
getDefaultFractionDigits(): java.util.Currency.getDefaultFractionDigits() meth
od returns default number of argumented currency fraction digits.
getDisplayName() : java.util.Currency.getDisplayName() method generates the
currency name of the argumented currency code.
getSymbol() : java.util.Currency.getSymbol() method returns Currency symbol
for the argumented currency code. In case, no symbol is returned normal currency
code will be returned.
lOMoARcPSD|36985876
FLOW CHART
lOMoARcPSD|36985876
CODE
ABOUT WINDOW.JAVA
package currencyConverter;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.border.EmptyBorder;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.net.URI;
import java.util.ResourceBundle;
public class AboutWindow extends JFrame {
private static final ResourceBundle BUNDLE =
ResourceBundle.getBundle("localization.translation"); //$NON-NLS-1$
private JPanel contentPane;
private static AboutWindow windowInstance = null;
private AboutWindow() {
setTitle(BUNDLE.getString("AboutWindow.this.title")); //$NON-NLS-1$
lOMoARcPSD|36985876
setBounds(100, 100, 347, 260);
setLocationRelativeTo(null);
setResizable( false );
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAuthor = new
JLabel(BUNDLE.getString("AboutWindow.lblAuthor.text")); //$NON-NLS-1$
lblAuthor.setHorizontalAlignment(SwingConstants.CENTER);
lblAuthor.setBounds(65, 122, 219, 33);
JLabel lblLink = new JLabel("http://jvinceno.fr");
lblLink.setBounds(65, 159, 219, 33);
lblLink.setHorizontalAlignment(SwingConstants.CENTER);
lblLink.setForeground(Color.BLUE);
lblLink.setCursor(new Cursor(Cursor.HAND_CURSOR));
lblLink.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI("http://www.jvinceno.fr"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
contentPane.setLayout(null);
JLabel lblTitle = new JLabel("Currency Converter");
lOMoARcPSD|36985876
lblTitle.setBounds(65, 12, 219, 33);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setFont(new Font("Noto Sans", Font.BOLD, 15));
contentPane.add(lblTitle);
CURRENCY.JAVA
package currencyConverter;
import java.util.ArrayList;
import java.util.HashMap;
public class Currency {
private String name;
private String shortName;
private HashMap<String, Double> exchangeValues = new HashMap<String, Double>();
public Currency(String nameValue, String shortNameValue) {
this.name = nameValue;
this.shortName = shortNameValue;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getShortName() {
lOMoARcPSD|36985876
return this.shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public HashMap<String, Double> getExchangeValues() {
return this.exchangeValues;
}
public void setExchangeValues(String key, Double value) {
this.exchangeValues.put(key, value);
}
public void defaultValues() {
String currency = this.name;
switch (currency) {
case "US Dollar":
this.exchangeValues.put("USD", 1.00);
this.exchangeValues.put("EUR", 0.93);
this.exchangeValues.put("GBP", 0.66);
this.exchangeValues.put("CHF", 1.01);
this.exchangeValues.put("CNY", 6.36);
this.exchangeValues.put("JPY", 123.54);
break;
case "Euro":
this.exchangeValues.put("USD", 1.073);
this.exchangeValues.put("EUR", 1.00);
lOMoARcPSD|36985876
this.exchangeValues.put("GBP", 0.71);
this.exchangeValues.put("CHF", 1.08);
this.exchangeValues.put("CNY", 6.83);
this.exchangeValues.put("JPY", 132.57);
break;
case "British Pound":
this.exchangeValues.put("USD", 1.51);
this.exchangeValues.put("EUR", 1.41);
this.exchangeValues.put("GBP", 1.00);
this.exchangeValues.put("CHF", 1.52);
this.exchangeValues.put("CNY", 9.60);
this.exchangeValues.put("JPY", 186.41);
break;
case "Swiss Franc":
this.exchangeValues.put("USD", 0.99);
this.exchangeValues.put("EUR", 0.93);
this.exchangeValues.put("GBP", 0.66);
this.exchangeValues.put("CHF", 1.00);
this.exchangeValues.put("CNY", 6.33);
this.exchangeValues.put("JPY", 122.84);
break;
case "Chinese Yuan Renminbi":
this.exchangeValues.put("USD", 0.16);
this.exchangeValues.put("EUR", 0.15);
this.exchangeValues.put("GBP", 0.11);
this.exchangeValues.put("CHF", 0.16);
this.exchangeValues.put("CNY", 1.00);
this.exchangeValues.put("JPY", 19.41);
break;
lOMoARcPSD|36985876
case "Japanese Yen":
this.exchangeValues.put("USD", 0.008);
this.exchangeValues.put("EUR", 0.007);
this.exchangeValues.put("GBP", 0.005);
this.exchangeValues.put("CHF", 0.008);
this.exchangeValues.put("CNY", 0.051);
this.exchangeValues.put("JPY", 1.000);
break;
}
}
public static ArrayList<Currency> init() {
ArrayList<Currency> currencies = new ArrayList<Currency>();
currencies.add( new Currency("US Dollar", "USD") );
currencies.add( new Currency("Euro", "EUR") );
currencies.add( new Currency("British Pound", "GBP") );
currencies.add( new Currency("Swiss Franc", "CHF") );
currencies.add( new Currency("Chinese Yuan Renminbi", "CNY") );
currencies.add( new Currency("Japanese Yen", "JPY") );
for (Integer i =0; i < currencies.size(); i++) {
currencies.get(i).defaultValues();
}
return currencies;
}
public static Double convert(Double amount, Double exchangeValue) {
Double price;
price = amount * exchangeValue;
lOMoARcPSD|36985876
price = Math.round(price * 100d) / 100d;
return price;
}
}
CURRENCY CONVERTER.JAVA
package currencyConverter;
import java.awt.EventQueue;
import javax.swing.UIManager;
public class CurrencyConverter {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e) {
e.printStackTrace();
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainWindow mainWindow = new MainWindow();
mainWindow.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
lOMoARcPSD|36985876
}
}
JTEXTFIELDLIMIT.JAVA
package currencyConverter;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
public class JTextFieldLimit extends PlainDocument {
private int limit;
private boolean toUppercase = false;
JTextFieldLimit(int limit) {
super();
this.limit = limit;
}
JTextFieldLimit(int limit, boolean upper) {
super();
this.limit = limit;
toUppercase = upper;
}
public void insertString
(int offset, String str, AttributeSet attr)
throws BadLocationException {
if (str == null) return;
if ((getLength() + str.length()) <= limit) {
if (toUppercase) str = str.toUpperCase();
lOMoARcPSD|36985876
super.insertString(offset, str, attr);
}
}
}
MAIN WINDOW.JAVA
package currencyConverter;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import java.util.ResourceBundle;
public class MainWindow extends JFrame {
private static final ResourceBundle BUNDLE =
ResourceBundle.getBundle("localization.translation");
lOMoARcPSD|36985876
private JPanel contentPane;
private JTextField fieldAmount;
private ArrayList<Currency> currencies = Currency.init();
public MainWindow() {
setTitle(BUNDLE.getString("MainWindow.this.title"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 589, 300);
setLocationRelativeTo(null);
setResizable( false );
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnFile = new JMenu(BUNDLE.getString("MainWindow.mnFile.text"));
mnFile.setMnemonic(KeyEvent.VK_F);
menuBar.add(mnFile);
JMenuItem mntmQuit = new
JMenuItem(BUNDLE.getString("MainWindow.mntmQuit.text"));
mntmQuit.setMnemonic(KeyEvent.VK_Q);
mntmQuit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
mnFile.add(mntmQuit);
JMenu mnHelp = new JMenu(BUNDLE.getString("MainWindow.mnHelp.text"));
mnHelp.setMnemonic(KeyEvent.VK_H);
lOMoARcPSD|36985876
menuBar.add(mnHelp);
JMenuItem mntmAbout = new
JMenuItem(BUNDLE.getString("MainWindow.mntmAbout.text"));
mntmAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
AboutWindow.getInstance().setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
});
mntmAbout.setMnemonic(KeyEvent.VK_A);
mnHelp.add(mntmAbout);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblConvert = new
JLabel(BUNDLE.getString("MainWindow.lblConvert.text")); //$NON-NLS-1$
lblConvert.setHorizontalAlignment(SwingConstants.RIGHT);
lblConvert.setBounds(0, 14, 92, 15);
contentPane.add(lblConvert);
lOMoARcPSD|36985876
final JComboBox<String> comboBoxCountry1 = new JComboBox<String>();
comboBoxCountry1.setBounds(147, 7, 240, 28);
populate(comboBoxCountry1, currencies);
contentPane.add(comboBoxCountry1);
JLabel lblTo = new JLabel(BUNDLE.getString("MainWindow.lblTo.text"));
lblTo.setHorizontalAlignment(SwingConstants.RIGHT);
lblTo.setBounds(66, 54, 26, 15);
contentPane.add(lblTo);
final JComboBox<String> comboBoxCountry2 = new JComboBox<String>();
comboBoxCountry2.setBounds(147, 47, 240, 28);
populate(comboBoxCountry2, currencies);
contentPane.add(comboBoxCountry2);
final JLabel lblAmount = new
JLabel(BUNDLE.getString("MainWindow.lblAmount.text")); //$NON-NLS-1$
lblAmount.setHorizontalAlignment(SwingConstants.RIGHT);
lblAmount.setBounds(23, 108, 69, 15);
contentPane.add(lblAmount);
fieldAmount = new JTextField();
fieldAmount.setText("0.00");
fieldAmount.setBounds(147, 101, 103, 29);
contentPane.add(fieldAmount);
fieldAmount.setColumns(10);
fieldAmount.setDocument(new JTextFieldLimit(8));
final JLabel lblResult = new JLabel("");
lblResult.setHorizontalAlignment(SwingConstants.LEFT);
lblResult.setBounds(147, 188, 428, 38);
lOMoARcPSD|36985876
contentPane.add(lblResult);
JButton btnConvert = new
JButton(BUNDLE.getString("MainWindow.btnConvert.text")); //$NON-NLS-1$
btnConvert.setBounds(147, 142, 129, 38);
btnConvert.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String nameCurrency1 = comboBoxCountry1.getSelectedItem().toString();
String nameCurrency2 = comboBoxCountry2.getSelectedItem().toString();
String result;
String formattedPrice;
String formattedAmount;
Double price;
Double amount = 0.0;
DecimalFormat format = new DecimalFormat("#0.00");
try {
amount = Double.parseDouble( fieldAmount.getText() ) ;
} catch (NumberFormatException e) {
e.printStackTrace();
amount = 0.0;
}
price = convert(nameCurrency1, nameCurrency2, currencies, amount);
formattedPrice = format.format(price);
formattedAmount = format.format(amount);
result = formattedAmount + " " + nameCurrency1 + " = " + formattedPrice + " " +
nameCurrency2;
lblResult.setText(result);
}
});
lOMoARcPSD|36985876
contentPane.add(btnConvert);
}
public static void populate(JComboBox<String> comboBox, ArrayList<Currency>
currencies) {
for (Integer i = 0; i < currencies.size(); i++) {
comboBox.addItem( currencies.get(i).getName() );
}
}
public static Double convert(String currency1, String currency2, ArrayList<Currency>
currencies, Double amount) {
String shortNameCurrency2 = null;
Double exchangeValue;
Double price = 0.0;
for (Integer i = 0; i < currencies.size(); i++) {
if (currencies.get(i).getName() == currency2) {
shortNameCurrency2 = currencies.get(i).getShortName();
break;
}
}
if (shortNameCurrency2 != null) {
for (Integer i = 0; i < currencies.size(); i++) {
if (currencies.get(i).getName() == currency1) {
exchangeValue =
currencies.get(i).getExchangeValues().get(shortNameCurrency2);
price = Currency.convert(amount, exchangeValue);
break;
}
}
lOMoARcPSD|36985876
return price;
}}
OUTPUT
US DOLLAR -TO- EURO
US DOLLAR -TO- BRITISH POUND
lOMoARcPSD|36985876
US DOLLAR -TO- SWISS FRANC
US DOLLAR -TO- JAPANESE YEN
lOMoARcPSD|36985876