Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SimpleCalculations;
- import java.io.IOException;
- import java.util.Objects;
- import java.util.Scanner;
- public class CurrencyConverter {
- public static void main(String[] args) throws IOException {
- Scanner console = new Scanner(System.in);
- double eur = 1.95583;
- double gbp = 2.53405;
- double usd = 1.79549;
- double a = Double.parseDouble(console.nextLine());
- String b = console.nextLine();
- String c = console.nextLine();
- double val = 0.0;
- double val1= 0.0;
- if (Objects.equals(b, "BGN"))
- {
- val = a;
- }
- if (Objects.equals(b, "EUR"))
- {
- val = a * eur;
- }
- if (b.equals("USD")) {
- val = a * usd;
- }
- if (Objects.equals(b, "GBP")) {
- val = a * gbp;
- }
- ////System.out.println(val);
- ////System.in.read();
- if (Objects.equals(c, "BGN")) {
- val1 = val; // triabva da ima posledovatelnost, taka se definirat, triabva double или decimal всички да са еднакви
- System.out.printf("%.2f %s", val1, c);
- }
- if (Objects.equals(c, "EUR")) {
- val1 = val / eur;
- System.out.printf("%.2f %s", val1, c);
- }
- if (Objects.equals(c, "USD"))
- {
- val1 = val / usd;
- System.out.printf("%.2f %s", val1, c);
- }
- if (Objects.equals(c, "GBP")) {
- val1 = val / gbp;
- System.out.printf("%.2f %s", val1, c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement