Advertisement
lily09290110

減法字串處理

Jan 19th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package cc.openhome;
  2. import java.math.BigDecimal;
  3. import java.util.Scanner;
  4. public class main {
  5.     public static void main(String[] args) {
  6.       Scanner com=new Scanner(System.in);
  7.       System.out.printf("減法運算\n");
  8.       //字串處理運算宣告(可運算數值擴大且為精確運算
  9.        BigDecimal []op;
  10.        op=new BigDecimal[5];
  11.        
  12.       System.out.printf("請輸入數字a:");
  13.       op[0]=new BigDecimal(com.next());
  14.       System.out.printf("請輸入數字b:");
  15.       op[1]=new BigDecimal(com.next());
  16.       System.out.printf(" a-b= %.2f\n",op[0].subtract(op[1]));
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement