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

热点内容
苹果无法指纹支付密码 浏览:63
怎么查看工作目录里的文件名 浏览:525
华为黄app怎么下载 浏览:342
禁用U盘怎么传输文件 浏览:88
wifi万能密码旧版 浏览:340
linux如何传文件虚拟机 浏览:929
word支持的文件类型 浏览:286
sfc转移号怎么编程 浏览:860
平面设计教程的书籍 浏览:676
扫描后的文件还能改么 浏览:21
微信代码怎么没用了 浏览:65
2013款卡罗拉原装导航怎么升级 浏览:860
微信扫描下载苹果app 浏览:29
70炼金术升级 浏览:862
C文件检验 浏览:101
IccID未知是有网络锁吗 浏览:101
苹果5s怎么定位苹果6手机 浏览:556
苹果手机港版怎么解锁 浏览:189
根据xml规则读取excel文件 浏览:28
网络删除文件 浏览:325

友情链接