answersLogoWhite

0

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

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake

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