import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
/**
* 结构-06. 复数四则运算
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
double a1 = s.nextDouble();
double b1 = s.nextDouble();
double a2 = s.nextDouble();
double b2 = s.nextDouble();
DecimalFormat format = new DecimalFormat("#0.0");
String fa1 = format.format(a1);
String fb1 = format.format(b1);
String fa2 = format.format(a2);
String fb2 = format.format(b2);
String output = null;
// *********加法***********/
double result1 = a1 + a2;
double result2 = b1 + b2;
String fs1 = format.format(result1);
String fs2 = format.format(result2);
if (fs1.equals("-0.0")) {
fs1 = "0.0";
}
if (fs2.equals("-0.0")) {
fs2 = "0.0";
}
String str1 = "(" + fa1 + (b1 >= 0 ? &
结构-06. 复数四则运算
最新推荐文章于 2021-05-24 09:44:29 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)