programmes

Ads

 
 

Share on Google+Share on Google+

ashhu
programmes
1 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
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;
this.b=b;
}
public String getComplexValue(){
if(this.b < 0){
return a+""+b+"i";
}
else{
return a+"+"+b+"i";
}
}

public static String addition(ComplexNumber num1, ComplexNumber num2){
int a1= num1.a+num2.a;
int b1= num1.b+num2.b;
if(b1<0){
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;
if(b1<0){
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;
vi=vi1+vi2;
if(vi<0){
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(com1.getComplexValue());
System.out.println(com2.getComplexValue());
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));
}
}

Thanks
RoseIndia Team

Ads









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
Advertisements
iPhone Application Development
for developing programmes for Mac OS X. The two major tools used for developing
Java Gui - Java Beginners
Java Gui  HOW TO ADD LINK LABELS IN JAVA PROGRAMMES
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
char array java
char array java  char array programmes in java All capital letters should be replaced with the next letter
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
Not Yet Solved - JSP-Servlet
and for all my programmes. i created a servlet to validates ten user details
making a web application using Web-Logic Server - Struts
help me for the same by showing the changes to be made in the programmes
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
still error
programmes with tools lik button,textfield etc.. and ds line "private void
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
Basic Syntax
and complex programmes
java bean - EJB
for the programmer where as in ejb these middle ware services are built in programmes
still error
making programmes with tools lik button,textfield etc.. and ds line "private void
iPhone Icon Design
programmes in itself and on the basis of icons we can recognize the applications
Oracle Corp. introduces updated version of Java
to force the small programmes known as Java Applets to run in the browser, when
JBBC ,MYSQL ND JAVA
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
JSF Training
try to apply the codes for developing the programmes, we claim that you
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
Kerala Beaches Tour
is reserved for cultural programmes like Kathakali dance performance. Return
Information on Tibet House Museum Delhi
is host to many lectures and programmes on Tibet and other related topics
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
PHP Training
for scripting the code for the simple programmes. In the third day, you will get

Ads

 
Advertisement null

Ads