这段代码在我提到的setScale()行中给出了一个错误; 它给我一个错误说Rounding必要.我正在尝试创建一个应用程序,它将接受cp和sp,然后根据利润/损失找到盈利/亏损百分比.有人可以帮我解决BigDecimal声明吗?
```java
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
abstract class functions
{
abstract void cpSP();
}
public class Percentage
{
static Scanner sc = new Scanner(System.in);
public void cpSP()
{
System.out.println("Enter the Cost Price:");
double CP = sc.nextDouble();
System.out.println("Enter the Selling Price:");
double SP = sc.nextDouble();
if (CP > SP)
{
System.out.println("As the Cost Price is greater than the Selling Price, there will be LOSS.");
System.out.println("Loss = CP - SP");
double loss = CP - SP;
System.out.println("Loss = " …Run Code Online (Sandbox Code Playgroud)