信息录入系统java代码,信息录入系统源码
用Java编写学生录入信息的程序
这里有一个类
创新互联建站主要从事成都做网站、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务禄丰,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
实现学生学号,数学,语文,英语成绩录入
并且计算平均成绩,按照平均成绩高低输出信息
你可以改改!
//实现简单的学生信息输入输出和初步的成绩排序
public class Student {
private int id; //学号
private int mathScore; //数学成绩
private int chinScore; //语文成绩
private int foreScore; //外语成绩
public Student() {
id = 0;
mathScore = 0;
chinScore = 0;
foreScore = 0;
}
public Student(int newId, int newMathScore, int newChinSvore,
int newForeScore) {
id = newId;
mathScore = newMathScore;
chinScore = newChinSvore;
foreScore = newForeScore;
}
public double getAverageScore() { //求平均成绩
double averageScore = ((double) mathScore + chinScore + foreScore) / 3;
return averageScore;
}
public void output(Student student) { //输出对象的内容
System.out.println(" " + student.id + " " + student.mathScore +
" " + student.chinScore + " "
+ student.foreScore + " " +
student.getAverageScore());
}
public int max(Student a[], int n) { //Student类对象数组的前n项中的成绩最大值的索引
int position = 0;
for (int i = 1; i n; i++) {
if (a[i].getAverageScore() a[position].getAverageScore()) { //比较平均成绩
position = i;
}
}
return position;
}
public void selectSort(Student a[]) { //Student类对象数组的选择排序
for (int n = a.length; n 1; n--) {
int i = max(a, n);
Student temp = a[i];
a[i] = a[n - 1];
a[n - 1] = temp;
}
}
}
要求编写一个java程序,输入学生信息,并能保存与显示学生信息。
import java.util.ArrayList;
import java.util.Scanner;import com.sun.org.apache.xpath.internal.Arg;
public class Student {
//两个私有属性
private int no ;
private String name ;
//默认构造函数
public Student(){}
//带参构造函数
public Student(int no,String name){
this.no=no;
this.name=name;
}
//添加学生信息
public void addStudentInfo(ArrayList list){
String flag1="yes";
do{
Student student=new Student();
Scanner in =new Scanner(System.in);
System.out.println("请输入学生学号:");
student.setNo(in.nextInt());
System.out.println("请输入学生姓名:");
student.setName(in.next());
list.add(student);
System.out.println("是否继续添加学生信息(yes/no)?");
flag1=in.next();
} while(flag1.equals("yes"));
}
//读取学生信息
public void showStudentInfo(ArrayListStudent list){
System.out.println(" 学生no: "+" 学生name: ");
for(Student student:list){
System.out.println(" "+student.getNo()+" "+student.getName());
}
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static void main(String arg[]) {
ArrayListStudent studentList= new ArrayListStudent();
Student student= new Student();
Scanner inn= new Scanner(System.in);
while(true){
System.out.println("----------------- 欢迎使用学生管理系统------------------");
System.out.println("1.输入学生信息");
System.out.println("2.显示学生信息");
System.out.println("0.退出系统");
System.out.println("请选择....");
int nn= inn.nextInt();
switch (nn) {
case 1:
student.addStudentInfo(studentList);
break;
case 2:
System.out.println("学生信息如下:");
student.showStudentInfo(studentList);
break;
case 0:
System.exit(0);
System.out.println("系统退出!");
break;
default:
break;
}
}
} }
Java实现简单个人信息录入
import java.util.Scanner;
public class 个人信息
{
public static void main(String[] args)
{
System.out.println("\n\t\t==========简单的个人信息录入==========\n");
init();
}//初始化!
private static void init()
{
for (; ; )
{
System.out.println("请输入姓名:");
String a=Input.getName();
System.out.println("请输入年龄:");
int b=Input.getAge();
System.out.println("请输入学历:");
String c=Input.getEducation();
System.out.println("你输入的信息^_^\t名字:"+a+" 年龄:"+b+" 学历:"+c+"\n");
}
}
}
class Input
{
private static Scanner sc=new Scanner(System.in);
private Input(){}
static String getName()
{
String name=sc.next();
return name;
}
static int getAge()
{
int age=sc.nextInt();
return age;
}
static String getEducation()
{
String education=sc.next();
return education;
}
}
当前标题:信息录入系统java代码,信息录入系统源码
文章路径:http://pwwzsj.com/article/dscpshc.html