文件名称:java中复数类的实现
文件大小:2KB
文件格式:JAVA
更新时间:2013-04-14 14:17:14
java 复数类
Scanner reader = new Scanner(System.in); System.out.println("请输入第一个复数的实部:"); Double x1 = reader.nextDouble(); System.out.println("请输入第一个复数的虚部:"); Double y1 = reader.nextDouble(); System.out.println("请输入第二个复数的实部:"); Double x2 = reader.nextDouble(); System.out.println("请输入第二个复数的虚部:"); Double y2 = reader.nextDouble(); Number num1 = new Number(x1,y1); Number num2 = new Number(x2,y2); System.out.println("相加的结果是:"+num1.Add(num2)); System.out.println("相减的结果是:"+num1.Jian(num2)); System.out.println("相乘的结果是:"+num1.Chen(num2));