-1

I exported my Java file, and its kind of working proberly.. theres just a little problem, that when the scanner have calculated my inputs, it outputs the result, but the application closes 1 sec after i recieved my output. How do i prevent my application from close?? the code is:

best regards

Oliver

import java.util.Scanner;
import java.util.HashMap;

import java.util.*;

public class Valuta {
    public static void main(String[] args){

        double euro, usd, gpb, dkk, done;

        Scanner input = new Scanner(System.in);

        System.out.println("Convert from " +"USD,GPB, DKK or EURO?");
        String temp = (input.nextLine()).toUpperCase();

        System.out.println("to " + "USD,GPB, DKK or Euro?");
        String tempp = (input.nextLine()).toUpperCase();

        Map<String, Double> lookUpMap = new HashMap<String, Double>(){{
            put("EURO", new Double(7.46));
            put("USD", new Double(5.56));
            put("GPB", new Double(8.84));
            put("DKK", new Double (1.0));
            }};


        System.out.println("amount of " + (temp));
        double amount = input.nextDouble();
        done = (lookUpMap.get(temp) / lookUpMap.get(tempp)) * amount;
        System.out.println(done);
    }
    }   
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Oliver Bak
  • 151
  • 12

1 Answers1

0

try this..

public static void main(String[] args) {

        double euro, usd, gpb, dkk, done;

        Scanner input = new Scanner(System.in);
        String ch = "";
        do{
        System.out.println("Convert from " + "USD,GPB, DKK or EURO?");
        String temp = (input.nextLine()).toUpperCase();
        System.out.println("to " + "USD,GPB, DKK or Euro?");
        String tempp = (input.nextLine()).toUpperCase();
        Map<String, Double> lookUpMap = new HashMap<String, Double>() {
            {
                put("EURO", new Double(7.46));
                put("USD", new Double(5.56));
                put("GPB", new Double(8.84));
                put("DKK", new Double(1.0));
            }
        };

        System.out.println("amount of " + (temp));
        double amount = input.nextDouble();
        done = (lookUpMap.get(temp) / lookUpMap.get(tempp)) * amount;
        System.out.println(done);
        System.out.println("Do you want continue ? Y/N");
        ch = input.nextLine();
        } while(ch.equals("Y"));
    }
subash
  • 3,116
  • 3
  • 18
  • 22