c语言sscanf函数的用法是什么
235
2023-01-02
Java实现学生信息管理界面
本文实例为大家分享了java实现学生信息管理界面的具体代码,供大家参考,具体内容如下
主类
package 学生信息管理系统;
public class Main {
public static void main(String[] args) {
// TODO 自动生成的方法存根
InterFace Menuhttp://=new InterFace();
Menu.menu();
}
}
添加信息
package 学生信息管理系统;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Scanner;
public class Add {
static Stu[] stu=new Stu[100];
static Scanner scanner=new Scanner(System.in);
static int number=0;
static InterFace Inter=new InterFace();
public void add() {
while(true) {
try {
clear();
} catch (AWTException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("请输入即将录入的人数:");
int N=scanner.nextInt();
for(int i=0;i stu[number]=new Stu(); System.out.println("请输入第"+(i+1)+"个学生的信息:"); System.out.println("请输入学号:"); stu[number].setNum(scanner.next()); System.out.println("请输入姓名:"); stu[number].setName(scanner.next()); System.out.println("请输入性别:"); stu[number].setSex(scanner.next()); System.out.println("请输入年龄:"); stu[number].setAge(scanner.nextInt()); System.out.println("请输入语文成绩:"); stu[number].setChinese(scanner.nextFloat()); System.out.println("请输入数学成绩:"); stu[number].setMath(scanner.nextFloat()); System.out.println("请输入英语成绩:"); stu[number].setEng(scanner.nextFloat()); number++; } System.out.println("录入完毕,即将返回!"); Inter.menu(); } } //实现控制台清屏 @SuppressWarnings("deprecation") public static void clear() throws AWTException { Robot r = new Robot(); r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键 r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键 r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键 r.keyPress(KeyEvent.VK_R); // 按下R键 r.keyRelease(KeyEvent.VK_R); // 释放R键 r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键 r.delay(100); } } 主界面 package 学生信息管理系统; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.*; public class InterFace { static Scanner scanner=new Scanner(System.in); public void menu(){ int select; try { clear(); } catch (AWTException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } do{ System.out.println("\t\t 欢迎使用学生信息管理系统\n"); System.out.println("\t\t *** ╭ □═■═□═■═□ ══╮***\n"); System.out.println("\t\t * │ 学生信息管理系统 │ *\n"); System.out.println("\t\t * ╰═══■═□═■═□═■╯ *\n"); System.out.println("\t\t * ┌───────────┐ *\n"); System.out.println("\t\t * │1.添加信息 2.加载信息│ *\n"); System.out.println("\t\t * │ │ *\n"); System.out.println("\t\t * │3.查询信息 4.文件操作│ *\n"); System.out.println("\t\t * │ │ *\n"); System.out.println("\t\t * │5.数据排序 6.修改信息│ *\n"); System.out.println("\t\t * │ │ *\n"); System.out.println("\t\t * │7.显示信息 8.删除信息│ *\n"); System.out.println("\t\t * │ │ *\n"); System.out.println("\t\t * │9.保存信息 0.退出系统│ *\n"); System.out.println("\t\t * └───────────┘ *\n"); System.out.println("\t\t ************************************\n"); System.out.println(); System.out.println("\t请选择操作方式(1~8):\n"); select=scanner.nextInt(); switch(select){ case 8: break; case 5: break; case 4: break; case 3: break; case 2: break; case 9: break; case 7: Show show=new Show(); show.show(); break; case 1: Add operate=new Add(); operate.add(); break; case 0: break; default: try { clear(); } catch (AWTException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } this.menu(); } }while(select!=8); } @SuppressWarnings("deprecation") public static void clear() throws AWTException { Robot r = new Robot(); r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键 r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键 r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键 r.keyPress(KeyEvent.VK_R); // 按下R键 r.keyRelease(KeyEvent.VK_R); uZFsOd // 释放R键 r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键 r.delay(100); } } 显示信息 package 学生信息管理系统; import java.util.Scanner; public class Show { int n = Add.number; static Scanner scanner=new Scanner(System.in); public void show() { System.out.println("**********************************************************"); System.out.println("学号 姓名 性别 年龄 语文 数学 英语"); for (int i = 0; i < n; i++) System.out.println(Add.stu[i].getNum() + " " +Add.stu[i].getName()+" "+ Add.stu[i].getSex() + " " + Add.stu[i].getAge() + " " + Add.stu[i].getChinese() + " " + Add.stu[i].getMath() + " " + Add.stu[i].getEng()); System.out.println("***************uZFsOd*******************************************"); System.out.println(); //n为毫秒数 try { Thread.sleep (100000) ; } catch (InterruptedException ie){} } } 学生类 package 学生信息管理系统; public class Stu { private String num; private String name; private String sex; private int age; private float chinese; private float math; private float eng; public String getNum() { return num; } public void setNum(String num) { this.num = num; } 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 int getAge() { return age; } public void setAge(int age) { this.age = age; } public float getChinese() { return chinese; } public void setChinese(float chinese) { this.chinese = chinese; } public float getMath() { return math; } public void setMath(float math) { this.math = math; } public float getEng() { return eng; } public void setEng(float eng) { this.eng = eng; } }
stu[number]=new Stu();
System.out.println("请输入第"+(i+1)+"个学生的信息:");
System.out.println("请输入学号:");
stu[number].setNum(scanner.next());
System.out.println("请输入姓名:");
stu[number].setName(scanner.next());
System.out.println("请输入性别:");
stu[number].setSex(scanner.next());
System.out.println("请输入年龄:");
stu[number].setAge(scanner.nextInt());
System.out.println("请输入语文成绩:");
stu[number].setChinese(scanner.nextFloat());
System.out.println("请输入数学成绩:");
stu[number].setMath(scanner.nextFloat());
System.out.println("请输入英语成绩:");
stu[number].setEng(scanner.nextFloat());
number++;
}
System.out.println("录入完毕,即将返回!");
Inter.menu();
}
}
//实现控制台清屏
@SuppressWarnings("deprecation")
public static void clear() throws AWTException
{
Robot r = new Robot();
r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键
r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键
r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键
r.keyPress(KeyEvent.VK_R); // 按下R键
r.keyRelease(KeyEvent.VK_R); // 释放R键
r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键
r.delay(100);
}
}
主界面
package 学生信息管理系统;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.*;
public class InterFace {
static Scanner scanner=new Scanner(System.in);
public void menu(){
int select;
try {
clear();
} catch (AWTException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
do{
System.out.println("\t\t 欢迎使用学生信息管理系统\n");
System.out.println("\t\t *** ╭ □═■═□═■═□ ══╮***\n");
System.out.println("\t\t * │ 学生信息管理系统 │ *\n");
System.out.println("\t\t * ╰═══■═□═■═□═■╯ *\n");
System.out.println("\t\t * ┌───────────┐ *\n");
System.out.println("\t\t * │1.添加信息 2.加载信息│ *\n");
System.out.println("\t\t * │ │ *\n");
System.out.println("\t\t * │3.查询信息 4.文件操作│ *\n");
System.out.println("\t\t * │ │ *\n");
System.out.println("\t\t * │5.数据排序 6.修改信息│ *\n");
System.out.println("\t\t * │ │ *\n");
System.out.println("\t\t * │7.显示信息 8.删除信息│ *\n");
System.out.println("\t\t * │ │ *\n");
System.out.println("\t\t * │9.保存信息 0.退出系统│ *\n");
System.out.println("\t\t * └───────────┘ *\n");
System.out.println("\t\t ************************************\n");
System.out.println();
System.out.println("\t请选择操作方式(1~8):\n");
select=scanner.nextInt();
switch(select){
case 8:
break;
case 5:
break;
case 4:
break;
case 3:
break;
case 2:
break;
case 9:
break;
case 7:
Show show=new Show();
show.show();
break;
case 1:
Add operate=new Add();
operate.add();
break;
case 0:
break;
default:
try {
clear();
} catch (AWTException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
this.menu();
}
}while(select!=8);
}
@SuppressWarnings("deprecation")
public static void clear() throws AWTException
{
Robot r = new Robot();
r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键
r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键
r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键
r.keyPress(KeyEvent.VK_R); // 按下R键
r.keyRelease(KeyEvent.VK_R); uZFsOd // 释放R键
r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键
r.delay(100);
}
}
显示信息
package 学生信息管理系统;
import java.util.Scanner;
public class Show {
int n = Add.number;
static Scanner scanner=new Scanner(System.in);
public void show() {
System.out.println("**********************************************************");
System.out.println("学号 姓名 性别 年龄 语文 数学 英语");
for (int i = 0; i < n; i++)
System.out.println(Add.stu[i].getNum() + " " +Add.stu[i].getName()+" "+ Add.stu[i].getSex() + " " + Add.stu[i].getAge() + " "
+ Add.stu[i].getChinese() + " " + Add.stu[i].getMath() + " " + Add.stu[i].getEng());
System.out.println("***************uZFsOd*******************************************");
System.out.println();
//n为毫秒数
try { Thread.sleep (100000) ;
} catch (InterruptedException ie){}
}
}
学生类
package 学生信息管理系统;
public class Stu {
private String num;
private String name;
private String sex;
private int age;
private float chinese;
private float math;
private float eng;
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public float getChinese() {
return chinese;
}
public void setChinese(float chinese) {
this.chinese = chinese;
}
public float getMath() {
return math;
}
public void setMath(float math) {
this.math = math;
}
public float getEng() {
return eng;
}
public void setEng(float eng) {
this.eng = eng;
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~