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

友情链接