java怎么编写java中怎么写复数的代码_⽤JAVA编写复数import java.util.Scanner;
public class Complex {
private double realPart;
private double imaginaryPart;
public Complex() {
}
public Complex(double realPart) {
super();
}
public Complex(double realPart, double imaginaryPart) {
super();
this.imaginaryPart = imaginaryPart;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("
输⼊第⼀个复数实部
:");
double realPart1 = Int();
System.out.print("
输⼊第⼀个复数虚部
:");
double imaginaryPart1 = Int();
System.out.print("
输⼊第⼀个复数实部
:");
double realPart2 = Int();
System.out.print("
输⼊第⼀个复数虚部
:");
double imaginaryPart2 = Int();
Complex c1 = new Complex(realPart1, imaginaryPart1); Complex c2 = new Complex(realPart2, imaginaryPart2); System.out.print("
加法
:");
Complex m = plus(c1, c2);
toString(m);
System.out.print("
除法:
");
Complex a = divideBy(c1, c2);
toString(a);
System.out.print("
减法:
");
Complex w = Minus(c1, c2);
toString(w);
System.out.print("
乘法:
");

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。