Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Java Currency Converter

Ads

 
 

Share on Google+Share on Google+

David Ferguson
Java Currency Converter
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners

Hi I was wondering if someone could help me write a program to convert Pounds into Euro's. The program should prompt the user to input the number of pounds and output the number of Euros this is equivalent to.

Thanks I have not had much luck with this

Ads
View Answers

October 25, 2011 at 11:10 AM


import java.text.*;
import java.util.*;

public class CurrencyConverter {
public static void main(String[] args) {
Double Exchange;
Double conversionToEuros;
Double Amount;

NumberFormat Pound1 = NumberFormat.getCurrencyInstance();
NumberFormat Euro1 = NumberFormat.getCurrencyInstance(Locale.FRANCE);
Conversion Converter1 = new Conversion();

Scanner scan = new Scanner(System.in);

System.out.println("Enter the current exchange rate(Pounds to Euros): " +"");
Exchange = scan.nextDouble();
Converter1.setExchange(Exchange);

System.out.println("Enter the amount you would like to exchange: " +"");
Amount = scan.nextDouble();
Converter1.setAmount(Amount);

System.out.println("Amount after conversion: " + Euro1.format(Converter1.conversionToEuros()));
}
}

class Conversion {

private double Exchange;
private double Amount;
private double conversionToEuros;
private double conversionToPounds;

public Conversion () {
}
public double getExchange() {
return Exchange;
}
public void setExchange (double currentRate) {
this.Exchange = currentRate;

}
public double getAmount() {
return Amount;
}
public void setAmount (double currentAmount) {
this.Amount = currentAmount;
}

public double conversionToEuros() {
return (Exchange * Amount);
}

public double conversionToPounds() {
return (Amount / Exchange);
}
}

Ads









Related Tutorials/Questions & Answers:
Java Currency Converter
Java Currency Converter   Hi I was wondering if someone could help me write a program to convert Pounds into Euro's. The program should prompt the user to input the number of pounds and output the number of Euros
Java array in currency converter
Java array in currency converter  Hi all, My sister is trying to teach me java. She's in school for programming and I'm not but I am just trying... not have any programming experience. Right now I am working on this currency
Advertisements
currency converter
currency converter  hi i have encountered a problem while creating a pdf file in jsp.... my problem is i want commas for the currency which is diplayed in the pdf file... i'm using sybase, stored procedure for the front end
Currency Converter in PHP - PHP
Currency Converter in PHP  Can anyone give me an idea on how to convert US dollar, Rupees, euro and yen to pounds
currency - Java Beginners
currency  helo guys can you share me a code about Currency... Mexican pesos sample input: ENTER TYPE OF CURRENCY:(so the user must choose a currency if dollars,swiss francs,euro dollars or mexican pesos)sample I input
currency - Java Beginners
currency  helo guys can you share me a "JAVAcode" about Currency...=9.815 Mexican pesos sample input: ENTER TYPE OF CURRENCY:(so the user must choose a currency if dollars,swiss francs,euro dollars or mexican pesos)sample I
converter
converter  I want to convert my c source code to java. Please tell me any software. How I convert c code to java code
how to do an measure converter in netbeans - Java Beginners
how to do an measure converter in netbeans   hi im not sure... information on joptionpane visit to : http://www.roseindia.net/java/java-tips/GUI/containers/20dialogs/10joptionpane.shtml http://www.roseindia.net/java/java-tips
converter application
converter application  Develop a converter application using event-driven programming paradigm of Java. Procedure: 1. Design a menu bar with two menus. 2. The first menu has the following menu items, Distance, Currency
Currency Symbol problem
Currency Symbol problem  Hi All, My Server side code...(); Currency currency = Currency.getInstance("MYR"); // Malaysia Code numberFormat.setCurrency(currency); int num = 12345; I want to print this in a JSP Page
currency conversion
currency conversion   hi frds.. I wan jsp code to convert currency in different formats??... if u know plz plz plz post it   Please visit the following link: http://www.roseindia.net/tutorials/I18N/currency
currency symbols in excel
currency symbols in excel  How to add a currency symbol in Excel sheet? Please guide me
javascript regex validate currency
javascript regex validate currency  How to validate currency in JavaScript?   <html> <head> <title>Currency validation... validate() { var currency = document.getElementById("currency").value
converter code for audio file
converter code for audio file  how can i convert a audio file to a another file format like mp3
pdf to voice converter
pdf to voice converter  is it possible to implement PDF to speech converter by extracting text from pdf and then text to speech
Why not use Double or Float to represent currency?
Why not use Double or Float to represent currency?  Why not use Double or Float to represent currency
Formatting and Parsing Locale-Specific Currency
Formatting and Parsing Locale-Specific Currency In this section, you will learn how to format and parse the locale specific currency. Through the formatting..., NumberFormat, Decimal format etc, Java has made programming easier. Here we
Currency Format Example
Currency Format Example       This Example shows you how to format currency according to the locale. In the code given below we are formatting Currency according to the locale. Methods
Version of geronimo>geronimo-converter dependency
List of Version of geronimo>geronimo-converter dependency
Version of spice>spice-converter dependency
List of Version of spice>spice-converter dependency
Version of com.nfbsoftware>latex-converter dependency
List of Version of com.nfbsoftware>latex-converter dependency
Version of cn.deathdealer>converter-fastjson dependency
List of Version of cn.deathdealer>converter-fastjson dependency
Version of com.nfbsoftware>latex-converter dependency
List of Version of com.nfbsoftware>latex-converter dependency
Doubt about Xstream Converter
Doubt about Xstream Converter  Hi, I am using the Xstream freamwork to read a lot of files in a batch operation. I use a custom converter Xstream to read some properties of my Xml file, but when I changed my application
Version of com.abubusoft>retrofit-converter-kripton dependency
List of Version of com.abubusoft>retrofit-converter-kripton dependency
Version of com.abubusoft>kripton-retrofit-converter dependency
List of Version of com.abubusoft>kripton-retrofit-converter dependency
Maven Dependency geronimo-converter >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-converter version1.1.1 in your project
Maven Dependency converter-fastjson >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of cn.deathdealer >> converter-fastjson version0.0.1 in your project
Maven Dependency latex-converter >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.nfbsoftware >> latex-converter version1.0.1 in your project
Maven Dependency geronimo-converter >> 1.0
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-converter version1.0 in your project