3.2Java作业

在这里插入代码片
```//冒泡排序
	public static void sort(int scores[]) {
		
		for (int i = 0; i < scores.length; i++) {
			for (int j = 0; j < scores.length-1-i; j++) {
				if (scores[j]>scores[j+1]) {
					int num = scores[j];
					scores[j]=scores[j+1];
					scores[j+1]=num;
				}
			}
		}
		
	}
```java
在这里插入代码片
```//选择排序
	public static void sort2(int scores[]) {
		int temp;
		int minIndex;
		for (int i = 0; i < scores.length-1; i++) {
			minIndex=i;
			for (int j = i+1; j < scores.length; j++) {
				if (scores[minIndex]>scores[j]) {
					minIndex=j;
				}
			}
			if (i!=minIndex) {
				temp= scores[i];
				scores[i]=scores[minIndex];
				scores[minIndex]=temp;
			}
		}
		
	}
```java
在这里插入代码片
```	//求数组最大值
	public static void maxNum(int scores[]) {
		int max =0;
		for (int i = 0; i < scores.length; i++) {
			if (scores[i]>scores[max]) {
				max=i;
			}
		}
		System.out.println(scores[max]);
	}
```java
在这里插入代码片
```//编写一个电脑类
public class Test2 {
	String displayCard;
	String brand;
	int money;
	String intemal;
	int size;
	int displaySize;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Test2 computer = new Test2();
		computer.displayCard="1050Ti";
		computer.brand="联想拯救者";
		computer.money=6000;
		computer.intemal="金士顿";
		computer.size=8;
		computer.displaySize=15;
		computer.detail();
		computer.look();
		computer.playGame();
		computer.study();
	}
	public  void look() {
		System.out.println("哈哈哈");
	}
	public  void playGame() {
		System.out.println("断剑重铸之日");
	}
	public  void study() {
		System.out.println("学个吊");
	}
	public  void detail() {
		System.out.println("显卡型号:"+displayCard);
		System.out.println("品牌:"+brand);
		System.out.println("价格:"+money);
		System.out.println("内存品牌:"+intemal);
		System.out.println("内存大小:"+size);
		System.out.println("显示器尺寸:"+displaySize);
	}

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值