Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.Format;
- import java.util.Scanner;
- /**
- * Created by Ivan Petrov on 10/2/2016.
- */
- public class p12_Calculator {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- double BGN = 1;
- double USD = 1.79549;
- double EUR = 1.95583;
- double GBP = 2.53405;
- double result;
- double amaunt = Double.parseDouble(console.nextLine());
- String inCurrency = console.nextLine();
- String outCurrency = console.nextLine();
- if (inCurrency.equals("GBP")) {
- BGN = GBP * amaunt;
- } else if (inCurrency.equals("EUR")){
- BGN = EUR * amaunt;
- } else if (inCurrency.equals("USD")){
- BGN = USD * amaunt;
- } else {
- BGN = amaunt;}
- if (outCurrency.equalsIgnoreCase("GBP")) {
- result = BGN / GBP;
- } else if (outCurrency.equalsIgnoreCase("EUR")){
- result = BGN / EUR;
- } else if (outCurrency.equalsIgnoreCase("USD")) {
- result = BGN / USD;
- } else result = BGN;
- System.out.printf("Result is %s %s", result, outCurrency);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment