Advertisement
udaykumar1997

l

Apr 28th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Complex
  2. {
  3. int Real,Imag;
  4. Complex()
  5. {}
  6. Complex(int Real1,int Imag1)
  7. {
  8. Real=Real1;
  9. Imag=Imag1;
  10. }
  11. Complex Add(Complex C1,Complex C2)
  12. {
  13. Complex CSum=new Complex();
  14. CSum.Real=C1.Real C2.Real;
  15. CSum.Imag=C1.Imag C2.Imag;
  16. return CSum;
  17. }
  18.  
  19. void Display()
  20. {
  21. System.out.println(Real " i" Imag);
  22. }
  23. }
  24.  
  25. class additionOfComplexNumbers
  26. {
  27. public static void main(String[] a)
  28. {
  29. Complex C1=new Complex(4,8);
  30. Complex C2=new Complex(5,7);
  31. Complex C3=new Complex();
  32. C3=C3.Add(C1,C2);
  33. System.out.print("SUM : ");
  34. C3.Display();
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement