0% found this document useful (0 votes)
4 views

advance java microproject 2

Java micro project

Uploaded by

atharvagarud43
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

advance java microproject 2

Java micro project

Uploaded by

atharvagarud43
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

CONTENT

Sr.no Chapters Page.no


1 Introduction 2
2 Procedure for Conversion 3
3 Code of Project 4-8
4 Explanation Of Code 9
5 Output of Code 10-11
6 Conclusion 12
7 Reference 12

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.

oney 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-sidedtowards


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.

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.

5) getSymbol() : java.util.Currency.getSymbol() method returnsCurrency


symbol for the argumented currency code. In case, nosymbol is returned
normal currency code will be returned.

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;

public class NewCconverter extends JFrame implements


ActionListener
{
JComboBox<String> fromcountry, tocountry;
JButton convert, reset, exit;
JLabel fromunit, tounit;
JTextField fromtext, Answer;

String[] currencyUnits = {"units", "Indian Rupee", "Pakistani


Rupee", "US Dollar", "Canadian Dollar",
"Kenyan Shilling", "Nigerian Naira", "Brazilian Real",
"Indonesian Rupiah", "Philippine Pisco"};

double Indian_Rupee = 95.21;


double Pakistani_Rupee = 162.74;
double US_Dollar = 1.31;
double Canadian_Dollar = 1.71;
double Kenyan_Shilling = 132.53;
double Nigerian_Naira = 476.57;
double Brazilian_Real = 5.47;
double Indonesian_Rupiah = 19554.94;
double Philippine_Pisco = 71.17;

NewCconverter() {
4
setBounds(300, 60, 790, 700);
getContentPane().setBackground(Color.LIGHT_GRAY);

JLabel maintitle = new JLabel("Currency Converter");


maintitle.setBounds(150, 30, 650, 60);
maintitle.setFont(new Font("Viner Hand ITC", Font.BOLD, 50));
maintitle.setForeground(Color.white);
add(maintitle);

JLabel from = new JLabel("From");


from.setBounds(10, 160, 50, 50);
from.setFont(new Font("Mongolian Baiti", Font.BOLD, 20));
from.setForeground(Color.white);
add(from);

fromcountry = new JComboBox<>(new String[]{"Select One..",


"India", "Pakistan", "USA", "Canada", "Kenyan",
"Nigeria", "Brazil", "Indonesia", "Philippine"});
fromcountry.setBounds(100, 165, 200, 40);
fromcountry.setFont(new Font("Mongolian Baiti", Font.BOLD,
20));
fromcountry.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
fromcountryItemStateChanged(evt);
}
});
add(fromcountry);

fromtext = new JTextField();


fromtext.setBounds(350, 165, 250, 40);
fromtext.setFont(new Font("Mongolian Baiti", Font.BOLD, 20));
fromtext.setForeground(Color.BLACK);
add(fromtext);

fromunit = new JLabel("Unit");


5
fromunit.setBounds(655, 185, 200, 40);
fromunit.setFont(new Font("Mongolian Baiti", Font.BOLD, 15));
fromunit.setForeground(Color.BLACK);
add(fromunit);

JLabel to = new JLabel("To");


to.setBounds(10, 310, 50, 50);
to.setFont(new Font("Mongolian Baiti", Font.BOLD, 20));
to.setForeground(Color.white);
add(to);

tocountry = new JComboBox<>(new String[]{"Select One..",


"India", "Pakistan", "USA", "Canada", "Kenyan",
"Nigeria", "Brazil", "Indonesia", "Philippine"});
tocountry.setBounds(100, 310, 200, 40);
tocountry.setFont(new Font("Mongolian Baiti", Font.BOLD,
20));
tocountry.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
tocountryItemStateChanged(evt);
}
});
add(tocountry);

Answer = new JTextField(" ");


Answer.setBounds(350, 310, 250, 40);
Answer.setFont(new Font("Mongolian Baiti", Font.BOLD, 20));
add(Answer);

tounit = new JLabel("Unit");


tounit.setBounds(655, 290, 250, 90);
tounit.setFont(new Font("Mongolian Baiti", Font.BOLD, 15));
tounit.setForeground(Color.BLACK);
add(tounit);

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);

reset = new JButton("Reset");


reset.setBounds(450, 450, 200, 40);
reset.setFont(new Font("Mongolian Baiti", Font.BOLD, 15));
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
fromcountry.setSelectedIndex(0);
tocountry.setSelectedIndex(0);
fromtext.setText(null);
Answer.setText(null);
}
});
add(reset);

exit = new JButton("Exit");


exit.setBounds(300, 550, 100, 40);
exit.setFont(new Font("Mongolian Baiti", Font.BOLD, 15));
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});
add(exit);

setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}

private void fromcountryItemStateChanged(ItemEvent evt) {


7
int position = fromcountry.getSelectedIndex();
fromunit.setText(currencyUnits[position]);
}

private void tocountryItemStateChanged(ItemEvent evt) {


int position = tocountry.getSelectedIndex();
tounit.setText(currencyUnits[position]);
}

public void actionPerformed(ActionEvent e) {

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

With help of many online website and guidance of subject teacher we


have completed our micro project.

We have also take help of many online websites:

https://www.geeksforgeeks.com.

https://www.javatpoint.com.

https://www.Github.com

12

You might also like