平时作业
java作业
package zuoye; public class zuoye02 { public static int Random(int n) { return (int)(n * Math.random()); } public static void main(String[] args) { int n = 100; //System.out.println(Random(n)); int[]random = new int[50]; for(int i = 0; i <50; i++) { random[i] = Random(n); } int max = random[0]; int min = random[0]; int count = 0; for(int num : random) { if(num > max) { max = num; } if(num < min) { min = num; } count++; } System.out.println("最大值为"+max); System.out.println("最小值为"+min); System.out.println("个数为"+count); } }
package zuoye; class Vehicle1{ private int speed; private int size; public void move() { } public void setSpeed(int speed) { this.speed = speed;//看不懂 } public void speedUp() { speed++; } public void speedDown() { if(speed>=0) { speed--; } } public int getSpeed() { return speed; } public int getSize() { return size; } public void setSize(int size) { this.size = size; } } public class Vehicle { public static void main(String[] args) { Vehicle1 v1 = new Vehicle1(); v1.setSpeed(10); v1.setSize(10); System.out.println("初始速度"+v1.getSpeed()); System.out.println("初始体积"+v1.getSize()); v1.speedUp(); System.out.println("加速后速度"+v1.getSpeed()); v1.speedDown(); System.out.println("减速后速度"+v1.getSpeed()); } }
打卡!打卡!打卡!打卡!打卡!