Question: programmes



Share on Google+Share on Google+

1 Answer(s)      8 years ago
Posted in : Java Beginners
View Answers

April 30, 2009 at 5:22 PM

Hi Friend,

Here is the full example code for your problem as given below. Please try the following code to solve your problem.

public class ComplexNumber
private int a;
private int b;
public ComplexNumber(){

public ComplexNumber(int a, int b){
this.a =a;
public String getComplexValue(){
if(this.b < 0){
return a+""+b+"i";
return a+"+"+b+"i";

public static String addition(ComplexNumber num1, ComplexNumber num2){
int a1= num1.a+num2.a;
int b1= num1.b+num2.b;
return a1+""+b1+"i";
} else {
return a1+"+"+b1+"i";

public static String substraction(ComplexNumber num1, ComplexNumber num2){
int a1= num1.a-num2.a;
int b1= num1.b-num2.b;
return a1+""+b1+"i";
} else {
return a1+"+"+b1+"i";

public static String multiplication(ComplexNumber num1, ComplexNumber num2){
int a1= num1.a*num2.a;
int b1= num1.b*num2.b;
int vi1 = num1.a * num2.b;
int vi2 = num2.a * num1.b;
int vi;
return a1-b1+""+vi+"i";
} else {
return a1-b1+"+"+vi+"i";

public static void main(String args[]){
ComplexNumber com1 = new ComplexNumber(-2,-3);
ComplexNumber com2 = new ComplexNumber(-4,-5);
System.out.println("Addition of both Complex Numbers are :" +ComplexNumber.addition(com1,com2));
System.out.println("Substraction of both Complex Numbers are :" +ComplexNumber.substraction(com1,com2));
System.out.println("Multiplication of both Complex Numbers are :" +ComplexNumber.multiplication(com1,com2));

RoseIndia Team


Related Tutorials/Questions & Answers:
java programmes - Java Beginners
java programmes  Can you please send me the programmes for IT Deptartment.The subject code is IT2305.Based on new syllabus as per Anna University for 2008 regulation.It contains 12 programmes
iPhone Application Development
for developing programmes for Mac OS X. The two major tools used for developing
Java GUI - Java Beginners
Java Gui - Java Beginners
char array java
char array java  char array programmes in java All capital letters should be replaced with the next letter
Not Yet Solved - JSP-Servlet
and for all my programmes. i created a servlet to validates ten user details
where to start - Java Beginners
where to start  Myself being a java beginner want to know wat is that I shall start practicing from the day one to make myself get the knowledge of java.Shall i get a series of questions or programmes for a beginner to work
making a web application using Web-Logic Server - Struts
help me for the same by showing the changes to be made in the programmes
still error
programmes with tools lik button,textfield etc.. and ds line "private void
generics - Java Beginners
generics  simple notes on Generics as well some programmes, with its added advantages for java...  Hi Friend, If you want to take an element from the Collection, you have to cast the type of element that is stored
Core Java Online Training
and developing programmes has become trendy jobs. To be a part of this contemporary... of a single page or a set of mini programmes or sections. The support for such programmes is provided through Struts, Server Pages (JSPs), Servlet API, etc. by Java
The Best We Offer
customised corporate training programmes with various business and technical needs... development programmes at our own business premises on timely basis
Oracle Corp. introduces updated version of Java
to force the small programmes known as Java Applets to run in the browser, when
iPhone Icon Design
programmes in itself and on the basis of icons we can recognize the applications
still error
making programmes with tools lik button,textfield etc.. and ds line "private void
java bean - EJB
for the programmer where as in ejb these middle ware services are built in programmes
Basic Syntax
and complex programmes
saved in a mysql table... plz if u've any such programmes kindly help me
Java Training Institute - Creating Ace Programmers
to survive the dreadful competitive scenario. Classroom Training: Various programmes
Information on Tibet House Museum Delhi
is host to many lectures and programmes on Tibet and other related topics
Kerala Beaches Tour
is reserved for cultural programmes like Kathakali dance performance. Return
Tips for Successful Outsourcing,Useful Tips of Successful Outsourcing,Tips and Techniques for Successful Outsourcing
. Programmes to bridge the gap should be held where both sides can come closer
JSF Training
try to apply the codes for developing the programmes, we claim that you
Big Data and Hadoop Training in Delhi
be handled and processed by the traditional software and there are special programmes
What is software programming?
a specific device or machine perform a function. The software or programmes written
Synchronization probleam - Java Server Faces Questions
Synchronization probleam   Hi friends My java multithreading listner consumes 99% of cpu time.please tell me how to synchronize this programme so that it runs normally like any other programmes. Here is my code
The Characteristics and Design of Web 2.0
programmes communicate one another using Application Programming Interface. The developer
Java Spring Hibernate Struts Training What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly?


Advertisement null