Tuesday, December 26, 2006
Monday, December 25, 2006
Lab Static Method, Part II
public class Complex
{
private double r,i;
public Complex(double newr,double newi)
{
r=newr;
i=newi;
}
public static Complex add(Complex c1,Complex c2)
{
Complex c3=new Complex(0,0);
c3.i=c1.i+c2.i;
c3.r=c1.r+c2.r;
return c3;
}
public Complex add(Complex c1)
{
Complex c3=new Complex(0,0);
c3.i=c1.i+i;
c3.r=c1.r+r;
return (c3);
}
public void output(){
System.out.println(this.r+"+" + this.i + "i");
}
}
/////
public class demo
{
public static void main(String[] args)
{
Complex c1 = new Complex(2,3);
Complex c2 = new Complex(4,5);
Complex c3 =Complex.add(c1,c2);
System.out.print("(2+3i)+(4+5i)=");
c3.output();
}}
Monday, December 18, 2006
Monday, December 11, 2006
Tuesday, December 05, 2006
Tuesday, November 28, 2006
Monday, November 27, 2006
Tuesday, November 21, 2006
Tuesday, November 07, 2006
Monday, November 06, 2006
Tuesday, October 31, 2006
Monday, October 30, 2006
Monday, October 23, 2006
Subscribe to:
Posts (Atom)