这是我在这里的第一篇文章,2周前开始编程,我无法弄清楚,为什么扫描仪"来自"和"到"没有将答案与其中一个双打连接,似乎只是试图将其转换成一个数字,我很困惑。任何帮助表示赞赏:)!
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double BGN = 1;
double USD = 1.79549;
double EUR = 1.95583;
double GBP = 2.53405;
double money = Double.parseDouble((in.nextLine()));
double from;
from = Double.parseDouble((in.nextLine()));
double to;
to = Double.parseDouble((in.nextLine()));
if (from == BGN && to == USD) {
System.out.println((money * BGN) / USD + " USD");}
else if (from == BGN && to == EUR){
System.out.println((money * BGN) / EUR + " EUR");}
else if (from == BGN && to == GBP){
System.out.println((money * BGN) / GBP + " GBP");}
else if (from == USD && to == BGN){
System.out.println((money * USD) / BGN + " BGN");}
else if (from == USD && to == EUR){
System.out.println((money * USD) / EUR + " EUR");}
else if (from == USD && to == GBP){
System.out.println((money * USD) / GBP + " GBP");}
else if (from == EUR && to == BGN){
System.out.println((money * EUR) / BGN + " BGN");}
else if (from == EUR && to == USD){
System.out.println((money * EUR) / USD + " USD");}
else if (from == EUR && to == GBP){
System.out.println((money * EUR) / GBP + " GBP");}
else if (from == GBP && to == BGN){
System.out.println((money * GBP) / BGN + " BGN");}
else if (from == GBP && to == USD){
System.out.println((money * GBP) / USD + " USD");}
else if (from == GBP && to == EUR){
System.out.println((money * GBP) / EUR + " EUR");}
else{
System.out.println("Invalid Answer");}
}
}