導航:首頁 > 編程語言 > 操作系統課程設計java

操作系統課程設計java

發布時間:2025-01-29 06:35:58

1. 求java程序!!!大一的java課程設計題目,求高手送程序~~~求大家幫忙啊~~~

完整的Java程序:

public class Test32 {
public static void main(String[] args) {
Complex c1 = new Complex(2, -1);
Complex c2 = new Complex(3, 4);
int m = 3;
System.out.println(c1.toString() + "的絕對值:" + c1.abs());
System.out.println(c1.toString() + "自增後:" + c1.addBySelf());
System.out.println(c1.toString() + "自減後:" + c1.subtractBySelf());
System.out.println("(" + c1.toString() + ") + (" + c2.toString() + ") = " + c1.add(c2));
System.out.println("(" + c1.toString() + ") - (" + c2.toString() + ") = " + c1.subtract(c2));
System.out.println("(" + c1.toString() + ") * (" + c2.toString() + ") = " + c1.multiply(c2));
System.out.println("(" + c1.toString() + ") / (" + c2.toString() + ") = " + c1.divide(c2));
System.out.println(c1.toString() + "的" + m + "次方 = " + c1.power(m));
}
}

//復數類:初始化復數、求其絕對值、復數的加、減、乘、除、乘方、自加、自減
class Complex{
protected double real; //實部
protected double image; //虛部

public Complex(){
real = image = 0;
}

public Complex(double real, double image){
this.real = real;
this.image = image;
}

//復數的絕對值
public Complex abs(){
return new Complex(Math.abs(this.real), Math.abs(this.image));
}

//復數相加
public Complex add(Complex c){
return new Complex(this.real + c.real, this.image + c.image);
}

//復數相減
public Complex subtract(Complex c){
return new Complex(this.real - c.real, this.image - c.image);
}

//復數相乘
public Complex multiply(Complex c){
return new Complex(this.real * c.real - this.image * c.image,
this.real * c.image + this.image * c.real);
}

//復數相除
public Complex divide(Complex c){
return new Complex((this.real * c.real + this.image * c.image) / (c.real * c.real + c.image * c.image),
(this.image * c.real - this.real * c.image) / (c.real * c.real + c.image * c.image));
}

//復數乘方
public Complex power(int m){
if(m < 0)
return new Complex();
if(m == 0)
return new Complex(1, 0);

Complex c = this;
for(int i=1; i<m; i++){
c = c.multiply(this);
}

return c;
}

//復數自增
public Complex addBySelf(){
return new Complex(++this.real, ++this.image);
}

//復數自減
public Complex subtractBySelf(){
return new Complex(--this.real, --this.image);
}

public String toString(){
if(this.real == 0)
if(this.image == 0)
return "0";
else
return this.image + "i";
else
if(this.image == 0)
return this.real + "";
else if(this.image > 0)
return this.real + "+" + this.image + "i";
else
return this.real + "" + this.image + "i";
}
}

運行測試:
2.0-1.0i的絕對值:2.0+1.0i
2.0-1.0i自增後:3.0
3.0自減後:2.0-1.0i
(2.0-1.0i) + (3.0+4.0i) = 5.0+3.0i
(2.0-1.0i) - (3.0+4.0i) = -1.0-5.0i
(2.0-1.0i) * (3.0+4.0i) = 10.0+5.0i
(2.0-1.0i) / (3.0+4.0i) = 0.08-0.44i
2.0-1.0i的3次方 = 2.0-11.0i

2. 計算機軟體技術都需要學習什麼課程呢

計算機軟體技術專業主要學習以下課程:

閱讀全文

與操作系統課程設計java相關的資料

熱點內容
IccID未知是有網路鎖嗎 瀏覽:101
蘋果5s怎麼定位蘋果6手機 瀏覽:556
蘋果手機港版怎麼解鎖 瀏覽:189
根據xml規則讀取excel文件 瀏覽:28
網路刪除文件 瀏覽:325
蘋果怎麼共享wifi網路列印機 瀏覽:368
怎麼用鍵盤拷貝u盤文件 瀏覽:664
js炫酷特效 瀏覽:69
什麼樣的app最有市場 瀏覽:563
騰訊地圖如何截圖工具 瀏覽:69
數據處理主要方法有哪些 瀏覽:567
ps6拖文件無法打開 瀏覽:668
有哪些比較好的書評app 瀏覽:520
java中char表示範圍 瀏覽:154
python編程操作題如何批改 瀏覽:1
網路是什麼原理圖 瀏覽:670
apk音樂提取工具 瀏覽:89
怎樣共享wifi密碼設置 瀏覽:281
javamesdk8 瀏覽:503
屬於聲音格式的文件有哪些 瀏覽:373

友情鏈接