简单的题目, 就是练习if...else if...else...语句的题目, 水题:
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] str = br.readLine().split(" "); int A = Integer.parseInt(str[0]); int B = Integer.parseInt(str[1]); if (B==0) { System.out.print(A+"/"+B+"=Error"); } else if(B > 0) { System.out.print(String.format(A + "/" + B + "=%.2f", (float)A/(float)B)); } else { System.out.print(String.format(A + "/" + "(" + B + ")" + "=%.2f", (float)A/(float)B)); } } }