answersLogoWhite

0


Best Answer

I found this class that defines complex numbers, and has the capacity of adding them, and much more:

http://www.math.ksu.edu/~bennett/jomacg/c.html

Basically, you define a class with two fields, one for the real part, and one for the imaginary part.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What program to add two Complex numbers in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


How do you write a programme to add two complex numbers?

Store your complex numbers in a structure of some sort that has two variables - one to store the real part and one to store the complex part. Then to add two complex numbers, add the real parts together and add the complex part together, eg: (2 + 3i) + (5 - 2i) = ((2 + 5) + (3 + -2)i) = (7 + i) how you actually do this will be entirely up to the language you are using for your programming.


How to solve imaginary complex numbers?

That depends a lot on what you want to solve. In general, you can do quite a lot by simply considering the complex number like any polynomial, and remembering that i2 = -1. For example, to add two complex numbers, you simply add the real and the imaginary part of both numbers.


How do you solve complex numbers?

That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.


How do you create a class of complex numbers?

I assume you refer to programming. Classes of complex numbers already exist for many programming languages (for instance, for Java); if you search for them, you can just use the ready-made classes, or - if you have a classroom task of writing your own class - at least get some useful ideas.The general idea is that you define a class with two fields - in Java that would be fields of type "double" - to store the real and imaginary part. Then you define methods for the desired operation and functions, such as addition, subtraction, multiplication, division, sine, cosine, exp, etc.As an example, to add two numbers, the method "add" can add the number in the object on which it is invoked, and the other number can be passed as a parameter (argument); the answer can be written back to the object. This would be equivalent to:a = a + bAs an alternative, you can pass two parameters (other complex numbers - i.e., other objects of the type "complex"), and make your object equal to the sum of the two. This would be equivalent to:a = b + c

Related questions

Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


What is add method in a java program?

If the "add" is part of the Java Collections API then calling c.add(o) adds an object o to the given collection (list or set). Likewise, the AWT API has add methods to add components to a Frame or Panel.


How do you find the average of 5 numbers using static method in java?

Add the five numbers; divide the result by 5.


How do you write a programme to add two complex numbers?

Store your complex numbers in a structure of some sort that has two variables - one to store the real part and one to store the complex part. Then to add two complex numbers, add the real parts together and add the complex part together, eg: (2 + 3i) + (5 - 2i) = ((2 + 5) + (3 + -2)i) = (7 + i) how you actually do this will be entirely up to the language you are using for your programming.


How do you add import packages to a java program in netbeans?

package thisPackage; import otherPackage.*; class myClass { }


How to solve imaginary complex numbers?

That depends a lot on what you want to solve. In general, you can do quite a lot by simply considering the complex number like any polynomial, and remembering that i2 = -1. For example, to add two complex numbers, you simply add the real and the imaginary part of both numbers.


How do you solve complex numbers?

That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.That depends what is the problem given, and what you want to solve. You may want to read an introductory article on complex numbers, to learn how you add them, multiply them, etc.


What are the similarities between vectors and complex numbers?

If you add two complex numbers, the resulting complex number is equivalent to the vector resulting from adding the two vectors. If you multiply two complex numbers, the resulting complex number is equivalent to the vector resulting from the cross product of the two vectors.


How do you add a variable from a Java program into a database through an SQL command within the Java program?

depends on the database you're trying to insert into for sql specifics, but... http://www.exampledepot.com/egs/java.sql/Insert.html provides a very good oracle answer/example.


What are the numbers when you add you get -3 when multiplied you get 40?

There are no two real numbers that do. Using complex numbers, these two do: (-3/2 + i√151/2) & (-3/2 - i√151/2) Two numbers that add to -3 and multiply to -40 are -8 & 5 Two numbers that add to 3 and multiply to -40 are 8 & -5 Two complex numbers that add to 3 and multiply to 40 are (3/2 + i√151/2) & (3/2 - i√151/2)


How do you write a java program to find the tax on the item and the item's total cost?

You simply multiply the tax rate with the item's original cost and divide by hundred, to get the tax. Then you add that to the original cost, to get the total cost. In Java you use + to add, * to multiply, and / to divide.