计算涨跌幅

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class StockRate {

	public static void main(String[] args) throws Exception {
		System.out.println("涨跌幅3.5个点");
		System.out.print("请输入  ");
		BufferedReader strin = new BufferedReader(new InputStreamReader(
				System.in));
		String input = strin.readLine();
		BigDecimal b1 = new BigDecimal(input);
		
		BigDecimal b2 = new BigDecimal(1.035);
		BigDecimal b3 = new BigDecimal(0.965);

		System.out.println("卖出: " + b1.multiply(b2).setScale(2, RoundingMode.HALF_UP)
				.doubleValue());
		System.out.println("买入: " + b1.multiply(b3).setScale(2, RoundingMode.HALF_UP)
				.doubleValue());

	}

}

你可能感兴趣的:(计算)