Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CurrencyConverter {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double amount = Double.parseDouble(scanner.nextLine());
- String currencyInput = scanner.nextLine();
- String currencyOutput = scanner.nextLine();
- double result=0.0;
- if (currencyInput.equals("BGN")){
- if (currencyOutput.equals("USD")){
- result =amount/ 1.79549;
- System.out.printf("%.2f USD", result);
- }
- else if (currencyOutput.equals("EUR")){
- result = amount/1.95583;
- System.out.printf("%.2f EUR", result);
- }
- else if (currencyOutput.equals("GBP")){
- result = amount/2.53405;
- System.out.printf("%.2f GBP", result);
- }
- else{
- result = amount;
- System.out.printf("%.2f BGN", result);
- }
- }
- else if (currencyInput.equals("USD")){
- if (currencyOutput.equals("BGN")){
- result =amount * 1.79549;
- System.out.printf("%.2f BGN", result);
- }
- else if (currencyOutput.equals("EUR")){
- result = amount/1.95583 * 1.79549;
- System.out.printf("%.2f EUR", result);
- }
- else if (currencyOutput.equals("GBP")){
- result = amount/2.53405 * 1.79549;
- System.out.printf("%.2f GBP", result);
- }
- else{
- result = amount;
- System.out.printf("%.2f USD", result);
- }
- }
- else if (currencyInput.equals("EUR")){
- if (currencyOutput.equals("USD")){
- result =amount/ 1.79549 * 1.95583;
- System.out.printf("%.2f USD", result);
- }
- else if (currencyOutput.equals("BGN")){
- result = amount * 1.95583;
- System.out.printf("%.2f BGN", result);
- }
- else if (currencyOutput.equals("GBP")){
- result = amount/2.53405 * 1.95583;
- System.out.printf("%.2f GBP", result);
- }
- else{
- result = amount;
- System.out.printf("%.2f EUR", result);
- }
- }
- else if (currencyInput.equals("GBP")){
- if (currencyOutput.equals("USD")){
- result =amount/ 1.79549 * 2.53405;
- System.out.printf("%.2f USD", result);
- }
- else if (currencyOutput.equals("EUR")){
- result = amount/1.95583 * 2.53405;
- System.out.printf("%.2f EUR", result);
- }
- else if (currencyOutput.equals("BGN")){
- result = amount * 2.53405;
- System.out.printf("%.2f BGN", result);
- }
- else{
- result = amount;
- System.out.printf("%.2f GBP", result);
- }
- }
- else{
- System.out.println("Invalid currency");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement