Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- public class CurrencyConverter {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- double ammount = Double.parseDouble(console.nextLine());
- String inputCurency = console.nextLine().toLowerCase();
- String outputCurrency = console.nextLine().toLowerCase();
- double totalAmmount = 0;
- double converted = 0;
- if(inputCurency.equals("bgn")){
- totalAmmount = ammount;
- }else if(inputCurency.equals("usd")) {
- totalAmmount = ammount * 1.79549;
- }else if(inputCurency.equals("eur")) {
- totalAmmount = ammount * 1.95583;
- }else if(inputCurency.equals("gbp")) {
- totalAmmount = ammount * 2.53405;
- }
- if(outputCurrency.equals("bgn")){
- converted = totalAmmount;
- }else if(outputCurrency.equals("usd")) {
- converted = totalAmmount / 1.79549;
- }else if(outputCurrency.equals("eur")) {
- converted = totalAmmount / 1.95583;
- }else if(outputCurrency.equals("gbp")) {
- converted = totalAmmount / 2.53405;
- }
- System.out.printf("%.2f %s", converted, outputCurrency );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment