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

成员变量:学号,姓名,性别,计算机成绩
成员方法:输入,总分,平均分
编程实现这个类,并调用相应的方法输入三个学生的数据,输出总分个平均分

第1个回答  推荐于2018-06-15
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());
}
}本回答被网友采纳
第2个回答  2018-06-14
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; }}追问

咱能分下段吗……这样看不懂啊

java编程:定义一个student类,包含内容如下
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());} } ...

定义一个Student类,包含以下内容如下: 成员变量:studentno,name,age...
include <iostream>#include <stdio.h>using namespace std;class Student{ char studentno[20]; char name[20]; int age; Student() { \/\/ 初始化 studentno = {0}; name = {0}; age = 0; } public: void printStudent() { cout << "学...

用java写程序,定义一个student类,包含的内容如下。成员变量:学号、姓 ...
public class Student { \/ param args \/ boolean master; \/\/定义成员变量 int num;String name,sex;double math,chinese,english,score=0.0,average=0.0;Student(int num,String name, String sex, boolean ma, double math, double chinese, double english ){ \/\/构造方法 this.num = n...

Java 定义一个Student类,包含内容如下: 成员变量——学号,姓名,性别,班...
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...

用JAVA定义一个学生类Student来表示学生信息,学生类中包含成员有学号...
Java是一种可以撰写跨平台应用程序的面向对象的程序设计语言。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群。Java 编程语言的风格十分接近C、C++语言。Java是一个纯的面向对象的程序...

定义一个“Student”类,包含的内容有: 成员变量:学号,姓名,性别,数学成...
public class Student { private int studentNo;private String studentName;private String sex;private int mathScore;private int chineseScore;public Student(){} public Student(int studentNO,String studentName){ this.studentNo=studentNO;this.studentName=studentName;} public int sum(int math...

编写一个JAVA程序,定义一个学生类Student,属性包含姓名,年龄,性别,根...
编写学生类Student,属性包含姓名,年龄,性别,根据该类分别创建五个学生对象,如下:public class Student {private String name;private int age;private String sex;public Student(String name,int age,String sex){this.name=name;this.age=age;this.sex=sex;}public static void main(String[] ...

定义一个表示学生信息的类Student,要求如下:
【答案】:(1)类Student的成员变量:sNO 表示学号;sName表示姓名;sSex表示性别;sAge表示年龄;sJava:表示Java课程成绩。(2)类Student的方法成员:getNo():获得学号;getName():获得姓名;class Student{private String sNO;private String sName;private char sSex;private int sAge;private int sJava;...

用java写程序,定义一个student类,包含成员变量有学号、姓名、性别、班...
public class Student {\\x0d\\x0a\\x0d\\x0a\/**\\x0d\\x0a * @param args\\x0d\\x0a *\/\\x0d\\x0aboolean master; \/\/定义成员变量\\x0d\\x0aint num;\\x0d\\x0aString name,sex;\\x0d\\x0adouble math,chinese,english,score=0.0,average=0.0;\\x0d\\x0a\\x0d\\x0aStudent(int...

JAVA 定义一个学生类(Student),包含学号、姓名、年龄(7-60岁)三个私 ...
import java.util.Scanner;class Student{ private String num;private int age;private String name;public Student(String b,String a,int c) { num=b;name=a;age=c;} public int reage() { return age;} void shou() { if(age>=7&&age<=60)System.out.println(name+" "+num+" "+...

相似回答