導航:首頁 > 編程語言 > 操作系統課程設計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相關的資料

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接