#27352: Java 簡易程式碼解答


s10914054@gm.cyut.edu.tw (Justin Tseng)

學校 : 不指定學校
編號 : 167107
來源 : [223.137.177.247]
最後登入時間 :
2022-08-30 17:42:14
a647. 投資專家 | From: [125.224.108.102] | 發表日期 : 2021-09-25 22:23

package zerojudge;

import java.math.*;

import java.util.*;

 

public class a647

{

public static void main(String[] args)

{

BigDecimal profit;

 

Scanner sc=new Scanner(System.in);

int test=sc.nextInt();

 

BigDecimal artwork[][]=new BigDecimal[test][2];

for(int i=0;i<test;i++)

{

artwork[i][0]=sc.nextBigDecimal();

artwork[i][1]=sc.nextBigDecimal();

 

profit=artwork[i][1].divide(artwork[i][0],30,RoundingMode.HALF_UP).subtract(BigDecimal.ONE).multiply(BigDecimal.valueOf(100));

System.out.print(profit.setScale(2,RoundingMode.HALF_UP));

if(profit.compareTo(BigDecimal.valueOf(10))>=0 || profit.compareTo(BigDecimal.valueOf(-7))<=0)

System.out.println("% dispose");

else

System.out.println("% keep");

}

 

sc.close();

}

}

 
ZeroJudge Forum