导航:首页 > 编程语言 > 操作系统课程设计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相关的资料

热点内容
沈阳如何用app办理个人养老 浏览:698
ps键盘教程 浏览:145
四个excel文件怎么合并 浏览:477
如何将手机视频导入文件管理 浏览:381
cfile读取多个文件 浏览:138
存放的文件有哪些 浏览:582
机器人编程课推广文案怎么写 浏览:950
更新爱思配置文件失败 浏览:420
邮箱文件过期怎么办 浏览:914
flashcs5视频教程下载 浏览:626
淘宝详情页源代码 浏览:239
查询车在哪里的app 浏览:905
苹果id怎么怎么输入代码是什么格式 浏览:861
游戏原声带放哪个文件夹 浏览:275
cad图形文件咋画 浏览:226
ios下载美区appstore 浏览:923
如何把相同颜色数据放在一起排列 浏览:82
qq群发送文件怎么撤回 浏览:825
ps不能使用文字工具 浏览:176
文件恢复软件哪个好用 浏览:861

友情链接