java成绩管理代码 java编写学生成绩管理的代码( 二 )


import java.util.Scanner;
class Stu {
private String name;
private float subject1;
private float subject2;
private float subject3;
public Stu() {
}
public Stu(String name) {
this.name = name;
}
public void setGrades(float subject1, float subject2, float subject3) {
this.subject1 = subject1;
this.subject2 = subject2;
this.subject3 = subject3;
}
public float getTotalGrades() {
return subject1 + subject2 + subject3;
}
public String toString() {
return this.name + "\t" + this.subject1 + "\t" + this.subject2 + "\t"
+ this.subject3 + "\t" + this.getTotalGrades();
}
}
public class J23020112204099 {
public static void main(String[] args) {
System.out.println("请输入学生信息");
Scanner input = new Scanner(System.in);
System.out.println("请输入要记录成绩的学生个数:");
int n = input.nextInt();
Stu[] stu = new Stu[n];
int i = 0;
System.out.println("请依次输入姓名,第一门成绩,第二门成绩,第三门成绩:");
for (i = 0; istu.length; i++) {
System.out.print("请输入第" + (i + 1) + "个人的姓名和成绩:");
stu[i] = new Stu(input.next());
stu[i].setGrades(input.nextFloat(), input.nextFloat(), input
.nextFloat());
}
J23020112204099 t = new J23020112204099();
t.sort(stu);
System.out.println("名次\tName\tSubject1\tSubject2\tSubject3\tTotal");
for (i = 0; istu.length; i++) {
System.out.print(i + 1 + "\t");
System.out.println(stu[i]);
}
}
// 排序
public void sort(Stu[] stu) {
int least = 0;
for (int i = 0; istu.length - 1; i++) {
least = i;
for (int j = i + 1; jstu.length; j++) {
if (stu[least].getTotalGrades()stu[j].getTotalGrades())
least = j;
}
if (i != least)
// 交换
swap(stu, i, least);
}
}
// 两个数交换
private void swap(Stu[] stu, int one, int two) {
Stu temp = stu[one];
stu[one] = stu[two];
stu[two] = temp;
}
}
//Scanner input=new Scanner(System.in);
//用来读取你的输入
//System.out.println("请输入要记录成绩的学生个数:"); int n=input.nextInt(); Stu[] stu=new Stu[n]; int i=0; System.out.println("请依次输入姓名,第一门成绩,第二门成绩 , 第三门成绩:"); for(i=0;istu.length;i++){ System.out.print("请输入第"+(i+1)+"个人的姓名和成绩:"); stu[i]=new Stu(input.next()); stu[i].setGrades(input.nextFloat(),input.nextFloat(),input.nextFloat()); }}
编写一个JAVA学生成绩管理类class student{
private String name;
private int score;
public student(String n,int s){name=n;score=s;}
public void setName(String n){name=n;}
public void setScore(int s){score=s;}
public void show(){System.out.println(name+"同学成绩是:"+score);}
}
public class test{
public static void main(String []dsafds){
student s=new student("xiaoming",100);
s.show();
s.setName("xiaogang");
s.setScore(50);
s.show();
}
}
求用Java编写的学生成绩管理系统的完整代码,要能运行的以下方法实现了用户界面登陆
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用户名java成绩管理代码:");//使用文本创建一个用户名标签
TextField t1=new TextField();//创建一个文本框对象
Label password=new Label("密码:");//创建一个密码标签
TextField t2=new TextField();
Button b1=new Button("登陆");//创建登陆按钮
Button b2=new Button("取消");//创建取消按钮
public DengLuJieMian()
{
this.setTitle("学生信息管理系统");//设置窗口标题

推荐阅读