我导出了我的Java文件,并且它的工作正常...这只是一个小问题,当扫描仪计算了我的输入时,它输出结果,但应用程序在我收到输出后1秒关闭。我如何阻止我的申请关闭?代码是:
最好的问候
奥利弗
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);
}
}
答案 0 :(得分:0)
试试这个..
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"));
}