#12499: RE java


zzser15963 (Momentary)

學校 : 國立新營高級中學
編號 : 57840
來源 : [110.30.168.151]
最後登入時間 :
2020-09-26 22:16:48
a021. 大數運算 | From: [211.20.149.151] | 發表日期 : 2017-08-01 11:49

package test;

import java.math.BigDecimal;
import java.util.Scanner;

public class pratice {

private static Scanner in;

public static void main(String[] args) {
in = new Scanner(System.in);
String a3;
String a4;
String symbol;
while (in.hasNext()) {
a3 = in.next();
symbol = in.next();
a4 = in.next();

BigDecimal B1 = new BigDecimal(a3);
BigDecimal B2 = new BigDecimal(a4);

if (symbol.equals("+")) {
System.out.println(B1.add(B2));
} else if (symbol.equals("-")) {
System.out.println(B1.subtract(B2));
} else if (symbol.equals("*")) {
System.out.println(B1.multiply(B2));
} else if (symbol.equals("/")) {
System.out.println(B1.divide(B2));
}

}

}

}

 
ZeroJudge Forum