java编程:定义一个student类,包含内容如下

成员变量:学号,姓名,性别,计算机成绩成员方法:输入,总分,平均分编程实现这个类,并调用相应的方法输入三个学生的数据,输出总分个平均分... 成员变量:学号,姓名,性别,计算机成绩
成员方法:输入,总分,平均分
编程实现这个类,并调用相应的方法输入三个学生的数据,输出总分个平均分
展开
 我来答
姣过手飘找人1Q
推荐于2018-06-15 · TA获得超过1904个赞
知道大有可为答主
回答量:2466
采纳率:70%
帮助的人:362万
展开全部
package com.tgyt.nzft.core.listview;

public class Student {

private String s_no;//学号
private String s_name;//姓名
private boolean isLeader;//班干部否
private String s_sex;//性别
private double s_shuxue;//数学
private double s_yuwen;//语文
private double s_waiyu;//外语

//学生信息录入
public void addStudentInfo(String s_no, String s_name, boolean isLeader, String s_sex,
double s_shuxue, double s_yuwen, double s_waiyu) {
this.s_no = s_no;
this.s_name = s_name;
this.isLeader = isLeader;
this.s_sex = s_sex;
this.s_shuxue = s_shuxue;
this.s_yuwen = s_yuwen;
this.s_waiyu = s_waiyu;
}

//获得总分
public double getTotal(){
return s_shuxue + s_yuwen + s_waiyu;
}

//平均分
public double getV(){
return getTotal() / 3;
}

public static void main(String[] args) {
Student student = new Student();
student.addStudentInfo("no_101", "女霸王", false, "女", 100, 35, 55);
System.out.println("总分:" + student.getTotal());
System.out.println("平局分:" + student.getTotal());
}
}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
智诺蕊4151
2018-06-14 · TA获得超过228个赞
知道答主
回答量:29
采纳率:100%
帮助的人:6.4万
展开全部
import java.util.Scanner; public class Student { public static void main(String[] args) { Student student = new Student(); student.input(); float sum = student.sum(); float avg = student.avg(); System.out.println("The "+student.getName()+"'s"+" sum is :" + sum); System.out.println("The "+student.getName()+"'s"+" avg is :"+ avg); } private int id; private String name; private String sex; private boolean leader; private float math; private float chinese; private float english; public void input(){ Scanner scanner = new Scanner(System.in); System.out.println("Pleace input the id:"); setId(scanner.nextInt()); System.out.println("Pleace input the name:"); setName(scanner.next()); System.out.println("Pleace input the sex:"); setSex(scanner.next()); System.out.println("Pleace input the weather leader:true or false"); setLeader(scanner.nextBoolean()); System.out.println("Pleace input the grade of math:"); setMath(scanner.nextFloat()); System.out.println("Pleace input the grade of chinese:"); setChinese(scanner.nextFloat()); System.out.println("Pleace input the grade of chinese:"); setEnglish(scanner.nextFloat()); } public float sum(){ float sum = this.math+this.chinese+this.english; return sum; } public float avg(){ return sum()/3; } public int getId() { return id; } public void setId(int id) { this.id = id; } 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 boolean isLeader() { return leader; } public void setLeader(boolean leader) { this.leader = leader; } public float getMath() { return math; } public void setMath(float math) { this.math = math; } public float getChinese() { return chinese; } public void setChinese(float chinese) { this.chinese = chinese; } public float getEnglish() { return english; } public void setEnglish(float english) { this.english = english; }}
追问
咱能分下段吗……这样看不懂啊
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式