急!!!JAVA课堂实验编程,求答案!!追分急!!

2024年11月22日 14:42
有2个网友回答
网友(1):

纯手打,2.(3)没搞清那个命令行是什么意思,所以没写乎罩悔

package student;

public class Student {

private String college;

private String major;

private String classes;

private String name;

private int oop;

private int network;

private int sql;

private int sum;

//无参构造函数

public Student(){}

//有参构造函数

public Student( String college,

String major, String classes, 

String name, int oop, int network,

int sql) {

super();

this.college = college;

this.major = major;

this.classes = classes;

this.name = name;

this.oop = oop;

this.network = network;

this.sql = sql;

}

//成员方法

public int sum(){

return oop+network+sql;


}

//getter,setter方法

public String getCollege() {

return college;

}

public void setCollege(String college) {

this.college = college;

}

public String getMajor() {

return major;

}

public void setMajor(String major) {

this.major = major;

}

public String getClasses() {

return classes;

}

public void setClasses(String classes) {

this.classes = classes;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getOop() {

return oop;

}

public void setOop(int oop) {

this.oop = oop;

}

public int getNetwork() {

return network;

}

public void setNetwork(int network) {

this.network = network;

}

public int getSql() {

return sql;

}

public void setSql(int sql) {

this.sql = sql;

}

//toString方法

@Override

public String toString() {

return "姓名:"+getName()+" "+"学院:"+getCollege()+" "+"专业:"+getMajor()

+" "+"班级"+getClasses()+" "+"总成绩:"+sum();

}

}

//测试类

package student;


import java.util.Scanner;


public class MyStudent {

public static void main(String[] args) {

//2.(1)

Student s=new Student();

s.setName("张三");

s.setCollege("南大");

s.setMajor("软件技术");

s.setClasses("软闷洞件1班");

s.setOop(89);

s.setNetwork(86);

s.setSql(99);

System.out.println(s);

System.out.println("------------------------------------"

+ "岁正--------------------------------------");

//2.(2)

Student s1=new Student("南大","软件技术","软件1班","李四", 88,98, 91);

System.out.println(s1);

System.out.println("-------------------------------"

+ "-----------------------------------------");


//2.(3)

Scanner a=new Scanner(System.in);

System.out.println("请输入学院:");

String college=a.next();

System.out.println("请输入专业:");

String major=a.next();

System.out.println("请输入班级:");

String classes=a.next();

System.out.println("请输入姓名:");

String name=a.next();

System.out.println("请输入面向对象程序设计成绩:");

int oop=a.nextInt();

System.out.println("请输入网络原理成绩:");

int network=a.nextInt();

System.out.println("请输入姓名数据库成绩:");

int sql=a.nextInt();

Student s2=new Student(college,major,classes,name,oop,network,sql);

System.out.println(s2);

}

}

网友(2):

看不清楚啊,兄弟。。