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 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 Complex Numbers are :" +ComplexNumber.addition(com1,com2));
jav-util.zip jav-util.zip i need to load a zipfile in to my class while executing and i have extract each file in that zip and a particular file content i need to desplay how can i do this please help me
JAv method overloading JAv method overloading What restrictions are placed on method overloading
jav beginners - Java Beginners jav beginners pl. let me know the logic and the program to print the prime and twin prim numbers
thanks Hi Friend,
Try the following code:
class TwinPrimes{
public static void main (String
Jav Applets - Applet Jav Applets I need to write a small payroll program, using applet, that provides a text field for the number of hours, a text field for the pay rate, and a non-editable text field for the output. It should also also provide
jav a - Design concepts & design patterns jav a Q.1. Write a program in Java to perform the addition of two complex numbers.
Hi Friend,
Try the following code:
public class ComplexNumber{
private int a;
private int b;
public ComplexNumber