public class Complex{
private float shibu;
private float xubu;
Complex()
{
this(0,0);
}
Complex(float shibu,float xubu){
this.shibu=shibu;
this.xubu=xubu;
}
public void Add(Complex p)
{
Complex result=new Complex();
result.shibu=this.shibu+p.shibu;
result.xubu=this.xubu+p.xubu;
System.out.print("加法果為:"+result.shibu+"+"+result.xubu+"i");
}
public static void main(String[] args) {
Complex fushu1=new Complex(1,2);
Complex fushu2=new Complex(3,4);
fushu1.Add(fushu2);
}
}
編寫一個完整的Java Applet 程序使用復(fù)數(shù)類Complex驗(yàn)證兩個復(fù)數(shù) 1+2i 和3+4i 相加產(chǎn)生一個新的復(fù)數(shù) 4+6i
編寫一個完整的Java Applet 程序使用復(fù)數(shù)類Complex驗(yàn)證兩個復(fù)數(shù) 1+2i 和3+4i 相加產(chǎn)生一個新的復(fù)數(shù) 4+6i
編寫一個完整的Java Applet 程序使用復(fù)數(shù)類Complex驗(yàn)證兩個復(fù)數(shù) 1+2i 和3+4i 相加產(chǎn)生一個新的復(fù)數(shù) 4+6i
復(fù)數(shù)類Complex必須滿足如下要求:
(1) 復(fù)數(shù)類Complex 的屬性有:
RealPart :int型,代表復(fù)數(shù)的實(shí)數(shù)部分
ImaginPart :int型,代表復(fù)數(shù)的虛數(shù)部分
(2) 復(fù)數(shù)類Complex 的方法有:
Complex( ) :構(gòu)造函數(shù),將復(fù)數(shù)的實(shí)部和虛部都置0
Complex( int r ,int i ) :構(gòu)造函數(shù),形參 r 為實(shí)部的初值,i為虛部的初值。
Complex complexAdd(Complex a) :將當(dāng)前復(fù)數(shù)對象與形參復(fù)數(shù)對象相加,所得的結(jié)果仍是一個復(fù)數(shù)值,返回給此方法的調(diào)用者。
String ToString( ) :把當(dāng)前復(fù)數(shù)對象的實(shí)部、虛部組合成 a+bi 的字符串形式,其中a 和 b分別為實(shí)部和虛部的數(shù)據(jù)。
編寫一個完整的Java Applet 程序使用復(fù)數(shù)類Complex驗(yàn)證兩個復(fù)數(shù) 1+2i 和3+4i 相加產(chǎn)生一個新的復(fù)數(shù) 4+6i
復(fù)數(shù)類Complex必須滿足如下要求:
(1) 復(fù)數(shù)類Complex 的屬性有:
RealPart :int型,代表復(fù)數(shù)的實(shí)數(shù)部分
ImaginPart :int型,代表復(fù)數(shù)的虛數(shù)部分
(2) 復(fù)數(shù)類Complex 的方法有:
Complex( ) :構(gòu)造函數(shù),將復(fù)數(shù)的實(shí)部和虛部都置0
Complex( int r ,int i ) :構(gòu)造函數(shù),形參 r 為實(shí)部的初值,i為虛部的初值。
Complex complexAdd(Complex a) :將當(dāng)前復(fù)數(shù)對象與形參復(fù)數(shù)對象相加,所得的結(jié)果仍是一個復(fù)數(shù)值,返回給此方法的調(diào)用者。
String ToString( ) :把當(dāng)前復(fù)數(shù)對象的實(shí)部、虛部組合成 a+bi 的字符串形式,其中a 和 b分別為實(shí)部和虛部的數(shù)據(jù)。
其他人氣:881 ℃時間:2020-05-23 16:50:54
優(yōu)質(zhì)解答
我來回答
類似推薦
- 用java定義一個復(fù)數(shù)類Complex,能夠創(chuàng)建復(fù)數(shù)對象,并且實(shí)現(xiàn)復(fù)數(shù)之間的加、減運(yùn)算
- 定義一個復(fù)數(shù)類Complex,使得下面的代碼能夠工作
- 已知平行四邊形的三個頂點(diǎn)A,B,D分別對應(yīng)復(fù)數(shù)2i,4-4i,2+6i,求四個頂點(diǎn)C對用應(yīng)的復(fù)數(shù)
- 設(shè)復(fù)數(shù)z滿足z^2=8+6i,求z^3-16z-(100/z)的值.
- 陳蕃的“蕃”在這里的讀音是什么?
- But the one million people of the city,who thought little of these events,were asleep as usual that
- 線粒體的氧化磷酸化和葉綠體的光合磷酸化有什么共同點(diǎn)和不同點(diǎn)?
- 一個含30度角的直角三角形能否分割成2個全等的三角形
- 設(shè)f(x)=√x,g(x)=-x+a(a>0,a∈R),若不等式▏{f(x)+a[g(x)-2a]}/f(x)▕ ≤1對x∈[1,4]恒成立,求a的取值范圍.小弟拜謝!
- 熱帶魚最適合的溫度是幾度?
- 有關(guān)圓周率的知識
- f(x)=|x²+3x|,關(guān)于x的方程f(x)-a|x-1|=0恰有4個互異的實(shí)根,則a的取值范圍
猜你喜歡
- 1用120個邊長是1cm的正方形,可以擺出 種面積是120平方厘米的長方形.
- 2m為何值時,方程組y=x+my2?4x?2y+1=0 (1)有兩組不相等的實(shí)數(shù)解; (2)有相同的兩組實(shí)數(shù)解; (3)無實(shí)數(shù)解.
- 3初一語文(下)主要復(fù)習(xí)什么?
- 4腦筋急轉(zhuǎn)彎:.How can you make a rope shorter without cutting or winding it?
- 5一根跳繩長五分之四米,這根跳繩的四分之三有多長?怎么算?
- 6人們在大自然中受到過哪些啟發(fā),有什么發(fā)明創(chuàng)造
- 7為什么before后面加being given而不是giving
- 8不要把污水直接排入河流英文怎么說
- 9兩個同體積的容器一個裝HCl氣體另一裝H2和CL2的混合氣體同溫同壓下,一定相同的是.
- 10五星村共有小麥的320公頃,玉米地比小麥地多1/4,這個村的玉米地比小麥地多多少公頃?玉米地有多少公頃?
- 11老外口中的的she average是什么意思
- 12大什么大什么,要成語的.