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

熱點內容
linux如何查看是否有共享文件夾 瀏覽:264
u盤拷貝文件以後為空 瀏覽:917
快雲主機資料庫連接方法 瀏覽:756
javagsp定位 瀏覽:384
jsp頁面表格導出excel 瀏覽:976
imagetest教程 瀏覽:244
怎樣將一個cad文件包圖紙兼容 瀏覽:898
論文有什麼好的網站 瀏覽:581
jdk7javadoc 瀏覽:687
編程小游戲是如何設計的 瀏覽:913
網路安全風險案例 瀏覽:46
司法考試哪個網站好 瀏覽:469
android搜索功能代碼 瀏覽:437
文件名如何沒有文字 瀏覽:601
吃雞地圖資源包文件路徑 瀏覽:267
cad文件轉移手機 瀏覽:733
指定區域網內文件delphi 瀏覽:638
蘋果5s充電介面維修 瀏覽:913
建行app怎麼老是信息填寫錯誤 瀏覽:832
羅技g903切換配置文件 瀏覽:649

友情鏈接