java编写风车代码 编程风车图案
怎么写java代码?
只要自己的电脑安装了jdk环境,任何地方都可以进行java代码的编写的,记事本也可以。
多端合一成都响应式网站建设公司:PC+平板+手机,同一后台修改数据多端同步更新提交您的需求,获取网站建设与营销策划方案报价,我们会在1小时内与您联系!
java实现风车旋转,为嘛我的画出来时一个圆在旋转
画之前加上g.clearRect(0, 0, getWidth(), getHeight());
不然你上一次画的还灶搭会呈现出来
这样呢,就会闪烁,需要使用双缓冲来解决了。厅亮
需要扮辩宽请追问。
请问如何用Java编写一个汽车类Car
public class Car {
private String color;//颜色
private int door;//车门数量
private float speed;//车速
public Car(){
this.color = "红色";
this.door = 3;
this.speed = 110;
}
public Car(String color, int door, float speed) {
this.color = color;
this.door = door;
this.speed = speed;
}
public void start(){
//汽车启动。输出汽车已启动,并输出汽车的各个属性
System.out.println("汽车已启动,汽车颜色为"+color+",车门数为"+door+",车速为"+speed);
}
public void speedUp(float speed){
//加速
System.out.println("汽车加速到"+speed+"km/h");
}
public void shutDown(float speed){
//减速
System.out.println("汽车减速到"+speed+"岁如凳km/h");
}
public void brake(){
//刹车
System.out.println("已刹车");
}
}
public class Test {
public static void main(String[] args){
Car car = new Car();
car.start();
car.speedUp(100);
car.shutDown(60);
car.brake();
Car car1 = new Car("乎旅白色",4,20.2F);
car1.start();
car1.speedUp(100);
car1.shutDown(60);
car1.brake();
}
}
运行橡游结果
用JAVA编写一个程序,要求如下:
实现代码如下:
Student类:
public class Student {
private String name;
private String sex;
private int age;
private double chinese;
private double math;
private double english;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getChinese() {
return chinese;
}
public void setChinese(double chinese) {
this.chinese = chinese;
}
public double getMath() {
return math;
}
public void setMath(double math) {
this.math = math;
}
public double getEnglish() {
return english;
}
public void setEnglish(double english) {
this.english = english;
}
}
-----------------------------------------------------------------
StudentTest类:腊誉(测试类)
import java.util.Scanner;
public class StudentTest {
public static void main(String[] args) {
Student student = new Student();
Scanner sc = new Scanner(System.in);
System.out.println("请输入姓名:");
student.setName(sc.next());
System.out.println("请输入性别:");
student.setSex(sc.next());
System.out.println("请输入年龄:");
student.setAge(sc.nextInt());
System.out.println("请滚衫输入语文成绩、数学成绩、英语成绩:");
student.setChinese(sc.nextDouble());
student.setMath(sc.nextDouble());
student.setEnglish(sc.nextDouble());
Double count = student.getChinese()+ student.getMath()+student.getEnglish();
System.out.println("姓名:"+student.getName()+" 性别:"+student.getSex()+" 年龄:"+student.getAge());
System.out.println("总分:"+count+" 平均分:"+count/3);
}
}
运行结果为大局腔:
当前题目:java编写风车代码 编程风车图案
文章网址:http://myzitong.com/article/ddpgpsg.html