package numeroscomp;
public class complejos {
double real1;
double real2;
double real3;
double imaginario1;
double imaginario2;
public complejos(){
this.real1 = 0;
this.real2 = 0;
this.real3 = 0;
this.imaginario1 = 0;
this.imaginario2 = 0;
}
public complejos(double real1, double real2, double real3, double imaginario1, double imaginario2) {
this.real1 = real1;
this.real2 = real2;
this.real3 = real3;
this.imaginario1 = imaginario1;
this.imaginario2 = imaginario2;
}
public double getReal1() {
return real1;
}
public void setReal1(double real1) {
this.real1 = real1;
}
public double getReal2() {
return real2;
}
public void setReal2(double real2) {
this.real2 = real2;
}
public double getReal3() {
return real3;
}
public void setReal3(double real3) {
this.real3 = real3;
}
public double getImaginario1() {
return imaginario1;
}
public void setImaginario1(double imaginario1) {
this.imaginario1 = imaginario1;
}
public double getImaginario2() {
return imaginario2;
}
public void setImaginario2(double imaginario2) {
this.imaginario2 = imaginario2;
}
public String desplegar(){
return ("("+ real1 + ", " + imaginario1 + "i)");
}
public String suma(){
return ("(" + (real1 + real2) + ", " + (imaginario1 + imaginario2) + "i)");
}
public String resta(){
return ("(" + (real1 - real2) + ", " + (imaginario1 - imaginario2) + "i)");
}
public String multiplicacion(){
return ("(" + (real1*real3) + ", " + (imaginario1*real1) + "i)");
}
public String division(){
return ("(" + (real1/real3) + ", " + (imaginario1/real1) + "i)");
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.