⽤java定义⼀个学⽣类_JAVA编写⼀个学⽣类匿名⽤户
3级
2009-10-08 回答
import java.util.Scanner;
public class Student1{
private String name;
private int computer_score;
private int english_score;
private int maths_score;
public void setName(String name){
this.name=name;
java怎么编写
System.out.println(this.name);
}
public void setComputer_score(){
System.out.print("计算机:");
Scanner scan=new Scanner(System.in);
computer_Int();
}
public void setEnglish_score(){
System.out.print("英语:");
Scanner scan=new Scanner(System.in);
english_Int();
}
public void setsetMaths_score(){
System.out.print("数学:");
Scanner scan=new Scanner(System.in);
maths_Int();
System.out.println();
}
public int getTotalScore(){
int total=computer_score+english_score+maths_score;
return total;
}
public void introduce(){
getTotalScore();
}
public static void main(String[] args){
Student1 xiaozhang=new Student1();
xiaozhang.setName("⼩张");
xiaozhang.introduce();
xiaozhang.setComputer_score();
xiaozhang.setEnglish_score();
xiaozhang.setsetMaths_score();
System.out.println("总分为:"+TotalScore()); }
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。