Problema con la división
Publicado por Clarence (11 intervenciones) el 14/10/2021 21:48:38
Buenos días, tengo un problema con la operación de la división, no entiendo que es lo que esta mal. Adjunto el código para que me puedan ayudar. Gracias. Tambien tengo que hacer la forma polar de un numero complejo pero sigo investigando como lograrlo ya que esto implica sacar el modulo del numero complejo y la tangente del real y el complejo.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.util.Scanner;
public class Complejos {
private double real, imaginario;
public Complejos() {
}
public Complejos(double real, double imaginario) {
this.real = real;
this.imaginario = imaginario;
}
public double getReal() {
return real;
}
public void setReal(double real) {
this.real = real;
}
public double getImaginario() {
return imaginario;
}
public void setImaginario(double imaginario) {
this.imaginario = imaginario;
}
public Complejos sumar(Complejos x) {
Complejos suma = new Complejos(real + x.getReal(), imaginario + x.getImaginario());
return suma;
}
public Complejos restar(Complejos x) {
Complejos resta = new Complejos(real - x.getReal(), imaginario - x.getImaginario());
return resta;
}
public Complejos multiplicar(Complejos x) {
Complejos producto = new Complejos((real * x.getReal() - imaginario * x.getImaginario()),
(real * x.getImaginario() + imaginario * x.getReal()));
return producto;
}
public Complejos dividir(Complejos x) {
Complejos division = new Complejos((real * x.getReal() + imaginario * x.getImaginario())
/ (x.getReal() * x.getReal() + x.getImaginario() * x.getImaginario()));
return division;
}
public Complejos formaPolar(Complejos x) {
Complejos polar = new Complejos(real * real + imaginario * imaginario);
}
public static void main(String[] args) {
Complejos num1, num2, suma, resta, producto, division;
double a, b, c, d;
Scanner sc = new Scanner(System.in);
System.out.println("Ingrese el primer numero complejo");
System.out.print("Ingrese la parte real: ");
a = sc.nextDouble();
System.out.print("Ingrese la parte imaginaria: ");
b = sc.nextDouble();
System.out.println("Ingrese el segundo numero complejo");
System.out.print("Ingrese la parte real: ");
c = sc.nextDouble();
System.out.print("Ingrese la parte imaginaria: ");
d = sc.nextDouble();
num1 = new Complejos(a, b);
num2 = new Complejos(c, d);
suma = num1.sumar(num2);
System.out.println("La suma es: " + suma.getReal() + " + " + suma.getImaginario() + "i");
resta = num1.restar(num2);
System.out.println("La resta es: " + resta.getReal() + " " + resta.getImaginario() + "i");
producto = num1.multiplicar(num2);
System.out.println("La multiplicacion es: " + producto.getReal() + " " + producto.getImaginario() + "i");
division = num1.dividir(num2);
System.out.println("La division es: " + division.getReal() + " " + division.getImaginario() + "i");
}
}
Valora esta pregunta


0