advance java microproject 2
advance java microproject 2
1
Currency Converter
Chapter 1: Introduction
cash converter is programming code that is intended to changeone 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.
2
Chapter 2: Procedure for conversion
Algorithm
1) getCurrency() : java.util.Currency.getCurrency()
getCurrency() : java.util.Currency.getCurrency()
2) getInstance() : java.util.Currency.getInstance()
method creates currency instance for Currency code.
3) getDefaultFractionDigits():
java.util.Currency.getDefaultFractionDigits() meth od returns
default number of argumented currency fraction digits.
4) getDisplayName() : java.util.Currency.getDisplayName()method
generates the currency name of the argumented currency code.
3
Chapter 3:Code of Project
package main.java;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
NewCconverter() {
4
setBounds(300, 60, 790, 700);
getContentPane().setBackground(Color.LIGHT_GRAY);
6
convert = new JButton("Convert Currency");
convert.setBounds(100, 450, 200, 40);
convert.setFont(new Font("Mongolian Baiti", Font.BOLD, 15));
convert.addActionListener(this);
add(convert);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
8
Chapter 4: Explanation of code
The provided code is a Java Swing application for a currency converter. It uses
graphical user interface components to allow the user to convert currency between
different units. Here's an explanation of how the code works:
The New Cconverter class extends J Frame and implements the Action Listener
interface. It sets up the main window for the currency converter application.
The class contains several Swing components like JComboBox, JButton, JLabel,
and JTextField, representing various input fields and buttons on the GUI.
The currency Units array holds the names of different currency units, and the
variables like Indian_Rupee, Pakistani_Rupee, etc., store the exchange rates
against the base currency unit (here, it's in Pounds).
The constructor New Cconverter() initializes the GUI components, sets their
positions, and adds action listeners where needed.
The from country Item State Changed and to country Item State Changed methods
are used to display the selected currency unit when the user chooses different
options from the "From" and "To" dropdowns.
The action Performed method is invoked when the user clicks the "Convert
Currency" button. It checks for valid inputs and performs the currency conversion
based on the selected currencies and the entered amount.
The currency conversion formula divides the input amount (in the base currency)
by the exchange rate of the "From" currency and then multiplies it by the exchange
rate of the "To" currency to get the converted amount.
The "Reset" button clears the input fields, and the "Exit" button closes the
application. The code doesn't handle real-time exchange rates or database storage.
The exchange rates are pre-defined in the code, and any changes to these rates
would require modifying the variables in the code itself.
9
Chapter 5: Output of Code
10
11
Chapter 6: Conclusion
In this micro project we have complete a micro project of Currency converter using
Advance java Language and we have also wrote a code an Output of Code. Our
code has been successfully run .
Chapter 7: Reference
https://www.geeksforgeeks.com.
https://www.javatpoint.com.
https://www.Github.com
12