Java实验,代码怎么写?Shape.java接口代码
public interface Shape {
public static final double PI = 3.14d;
public double area();
}
Circle.java圆类代码
public class Circle implements Shape {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
@Override
public double area() {
return PI * this.radius * this.radius;
}
public double perimeter() {
return 2 * PI * this.radius;
}
}
Cylinder.java圆柱体类代码
public class Cylinder extends Circle {
private double height;
public Cylinder(double radius, double height) {
super(radius);
this.height = height;
}
public double area() {
return 2 * super.area() + super.perimeter() * this.height;
}
public double volume() {
return super.area() * this.height;
}
}
X5_3_6.java主类代码
public class X5_3_6 {
public static void main(String[] args) {
Circle cir1 = new Circle(5);
System.out.println("圆的面积为:" + cir1.area());
System.out.println("圆的周长为:" + cir1.perimeter());
Cylinder cy1 = new Cylinder(10, 15);
System.out.println("圆柱体的表面积为:" + cy1.area());
System.out.println("圆柱体的体积为:" + cy1.volume());
}
}
上面是我写的代码,下图是执行结果 , 麻烦看一下,是否可以 。
求一Java程序代码?。?/h2>public class Matriculate{
private int score=400;
public int isMatriculate(Student stu){
if (stu.getIntgretResult()=score||(stu.getIntgretResult()=300stu.getSports()=90)) {
return 1;
}else {
return 0;
}
}
public static void main(String[] args) throws Exception {
Student stu1=new Student("zhangsan",1);
stu1.setIntgretResult(400);
Student stu2=new Student("lisi",2);
stu2.setSports(85);
stu2.setIntgretResult(356);
Matriculate m=new Matriculate();
int c1=m.isMatriculate(stu1);
if (c10) {
System.out.println("id:"+stu1.getId()+"\tname:"+stu1.getName()
+"\tIntgretResult:"+stu1.getIntgretResult()+"\tsports"+stu1.getSports());
System.out.println("被录取");
}
int c2=m.isMatriculate(stu2);
if (c20) {
System.out.println("id:"+stu2.getId()+"\tname:"+stu2.getName()
+"\tIntgretResult:"+stu2.getIntgretResult()+"\tsports"+stu2.getSports());
System.out.println("被录取");
}
}
}
class School{
public School(){}
public School(String schoolname, double scoreLine) {
this.schoolname = schoolname;
this.scoreLine = scoreLine;
}
private String schoolname;
private double scoreLine;
public String getSchoolname() {
return schoolname;
}
public double getScoreLine() {
return scoreLine;
}
}
class Student{
public Student(){}
public Student(String name, int id) {
this.name = name;
this.id = id;
}
private String name;
private int id;
private double intgretResult;
private int sports;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getIntgretResult() {
return intgretResult;
}
public void setIntgretResult(double intgretResult) {
this.intgretResult = intgretResult;
}
public int getSports() {
return sports;
}
public void setSports(int sports) {
this.sports = sports;
}
}
求JAVA源代码import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
推荐阅读
- oracle索引如何选择,oracle指定索引顺序
- 如何选择跨境电商货源,跨境电商应如何选择货源
- linux清屏幕命令,linux中清除屏幕显示的命令是什么
- php查看所有数据库 php查看所有数据库信息
- U盘签名叫什么,u盘签名写啥
- excel符号怎么清除,excel清除特殊符号
- 直播自制特效素材,直播自制特效素材下载
- 后端怎么进入mysql 后端连接mysql数据库
- gis制作附表,gis属性表附属性