import java.util.*;
import javax.swing.*;
class Plus{
private double real=1.0;
private double image=1.0;
public Plus(double r,double i){
real=r;
image=i;
}
public Plus(){
}
public double getReal(){
return real;
}
public double getImage(){
return image;
}
public double setreal(){
Scanner in=new Scanner(System.in);
real=in.nextDouble();
return real;
}
public double setimage(){
Scanner in=new Scanner(System.in);
image=in.nextDouble();
return image;
}
public static Plus addreal(Plus x,Plus y){
Plus result1=new Plus();
result1.real=x.real+y.real;
result1.image=x.image+y.image;
return result1;
}
public static Plus subreal(Plus z,Plus v){
Plus result2=new Plus();
result2.real=z.real-v.real;
result2.image=z.real-v.image;
return result2;
}
public String Ttostring(){
return (real+(image<0?"-"+image*(-1):"+"+image)+"i");
}
}
public class Complus{
public static void main(String [] args){
System.out.println("plase input your first complus' real and image:");
Plus a=new Plus();
a.setreal();
a.setimage();
System.out.println("plase input your second complus' real and image:");
Plus b=new Plus();
b.setreal();
b.setimage();
Plus result=new Plus();
JOptionPane.showMessageDialog(null,"a="+a.Ttostring()+"/n"+
"b="+b.Ttostring()+"/n"+"a+b="+result.addreal(a,b).Ttostring()+"/n"+
"a-b="+result.subreal(a,b).Ttostring(),"结果",JOptionPane.INFORMATION_MESSAGE);
}
}
import javax.swing.*;
class Plus{
private double real=1.0;
private double image=1.0;
public Plus(double r,double i){
real=r;
image=i;
}
public Plus(){
}
public double getReal(){
return real;
}
public double getImage(){
return image;
}
public double setreal(){
Scanner in=new Scanner(System.in);
real=in.nextDouble();
return real;
}
public double setimage(){
Scanner in=new Scanner(System.in);
image=in.nextDouble();
return image;
}
public static Plus addreal(Plus x,Plus y){
Plus result1=new Plus();
result1.real=x.real+y.real;
result1.image=x.image+y.image;
return result1;
}
public static Plus subreal(Plus z,Plus v){
Plus result2=new Plus();
result2.real=z.real-v.real;
result2.image=z.real-v.image;
return result2;
}
public String Ttostring(){
return (real+(image<0?"-"+image*(-1):"+"+image)+"i");
}
}
public class Complus{
public static void main(String [] args){
System.out.println("plase input your first complus' real and image:");
Plus a=new Plus();
a.setreal();
a.setimage();
System.out.println("plase input your second complus' real and image:");
Plus b=new Plus();
b.setreal();
b.setimage();
Plus result=new Plus();
JOptionPane.showMessageDialog(null,"a="+a.Ttostring()+"/n"+
"b="+b.Ttostring()+"/n"+"a+b="+result.addreal(a,b).Ttostring()+"/n"+
"a-b="+result.subreal(a,b).Ttostring(),"结果",JOptionPane.INFORMATION_MESSAGE);
}
}