6.28 周末 ATM 学生管理系统项目
来源:互联网 发布:js获取电子秤串口数据 编辑:程序博客网 时间:2024/06/09 19:48
1、 ATM 用的数组来做登陆
package 取款机;
import javax.swing.JOptionPane;
public class Zhoumo1 {
public static String numzu[] = { "123", "456", "789" };
public static String pwdzu[] = { "123", "456", "789" };
public static int moneyzu[] = { 2000, 3000, 5000 };
public static int index = -1;
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "欢迎光临威哥银行");
boolean t = login();
if (t == false) {
JOptionPane.showMessageDialog(null, "登陆失败");
System.exit(0);
} else {
JOptionPane.showMessageDialog(null, "登陆成功");
}
while (true) {
String i = JOptionPane.showInputDialog(null,
"请选择\n1、存款\n2、取款\n3、查询余额\n4、退卡");
int item = Integer.parseInt(i);
switch (item) {
case 1:
savemoney();
break;
case 2:
getmoney();
break;
case 3:
findmoney();
break;
case 4:
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null, "请输入1-4的选项");
break;
}
}
}
// 登陆界面
public static boolean login() {
for (int i = 0; i < 3; i++) {
String num = JOptionPane.showInputDialog(null, "输入卡号");
String pwd = JOptionPane.showInputDialog(null, "输入密码");
for (int j = 0; j < numzu.length; j++) {
if (num.equals(numzu[j]) && pwd.equals(pwdzu[j])) {
index = j;
return true;
}
}
JOptionPane.showMessageDialog(null, "账号或密码错误");
}
return false;
}
public static void savemoney() {
String a = JOptionPane.showInputDialog(null, "请把钱放在存款处");
int money = Integer.parseInt(a);
moneyzu[index] += money;
String s = JOptionPane.showInputDialog(null, "是否查余额 y\n");
if (s.equals("y")) {
findmoney();
}
}
public static void getmoney() {
String m=JOptionPane.showInputDialog(null,"请输入您要取走的钞票金额");
int money=Integer.parseInt(m);
if(money>moneyzu[index]){
JOptionPane.showMessageDialog(null, "S.B,余额不足");
}else{
moneyzu[index]-=money;
}
String s = JOptionPane.showInputDialog(null, "是否查余额 y\n");
if (s.equals("y")) {
findmoney();
}
}
public static void findmoney() {
JOptionPane.showMessageDialog(null, "您的账户余额为" + moneyzu[index]);
}
}
2、学生管理系统 自己定义了一个新的类型 .封装使用
import javax.swing.JOptionPane;
public class Zhoumo2 {
public static student2 student[] = new student2[20];
public static int num = 0;
public static int index = -1;
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "欢迎登陆学生管理系统");
boolean right = login();
if (right == false) {
JOptionPane.showMessageDialog(null, "密码都不知道,滚蛋");
} else {
JOptionPane.showMessageDialog(null, "登陆成功");
}
while (true) {
String s = JOptionPane.showInputDialog(null,
"请输入选项\n1、添加\n2、显示\n3、删除\n4、修改\n5、查询\n6、排序\n7、退出");
int item = Integer.parseInt(s);
switch (item) {
case 1:
add();
break;
case 2:
show();
break;
case 3:
delete();
break;
case 4:
change();
break;
case 5:
find();
break;
case 6:
arrange();
break;
case 7:
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null, "请输入1-7的选项");
break;
}
}
}
public static boolean login() {
boolean t = false;
for (int i = 0; i < 3; i++) {
String z = JOptionPane.showInputDialog(null, "请输入账号");
String pwd = JOptionPane.showInputDialog(null, "请输入密码");
if (z.equals("123") && pwd.equals("123")) {
return true;
} else {
JOptionPane.showMessageDialog(null, "账号或密码错误");
}
}
return false;
}
public static void add() {
in(num);
num++;
}
public static void show() {
String str = "学号 姓名 成绩\n";
for (int i = 0; i < num; i++) {
str += student[i].code + " " + student[i].name + " "
+ student[i].grade + "\n";
}
JOptionPane.showMessageDialog(null, str);
}
public static void delete() {
int gg = findxx();
if (gg == -1) {
JOptionPane.showMessageDialog(null, "查无此人");
}
if (gg != -1) {
for (int i = index; i < student.length - 1; i++) {
student[i] = student[i + 1];
}
num--;
}
show();
}
public static void change() {
int gg = findxx();
if (gg == -1) {
JOptionPane.showMessageDialog(null, "查无此人");
} else {
in(index);
}
show();
}
public static void find() {
int gg = findxx();
if (gg == -1) {
JOptionPane.showMessageDialog(null, "查无此人");
} else {
JOptionPane.showMessageDialog(null, "学号 " + student[index].code
+ " 姓名 " + student[index].name + " 成绩 "
+ student[index].grade);
}
}
public static void arrange() {
for (int i = 0; i < num; i++) {
for (int j = i + 1; j < num; j++) {
if (student[i].grade < student[j].grade) {
student2 temp = student[i];
student[i] = student[j];
student[j] = temp;
}
}
}
show();
}
// 定位
public static int findxx() {
String name = JOptionPane.showInputDialog(null, "请输入学生的姓名");
for (int i = 0; i < num; i++) {
if (name.equals(student[i].name)) {
index = i;
return i;
}
}
return -1;
}
public static void in(int num) {
String code = JOptionPane.showInputDialog(null, "请输入学生学号");
String name = JOptionPane.showInputDialog(null, "请输入学生姓名");
String grade = JOptionPane.showInputDialog(null, "请输入学生成绩");
student2 s = new student2();
s.code = code;
s.name = name;
s.grade = Integer.parseInt(grade);
student[num] = s;
}
}
- 6.28 周末 ATM 学生管理系统项目
- 学生管理系统 项目总结
- 学生管理系统项目演示
- 项目:学生管理系统[C++]
- ATM机管理系统
- 学生管理系统之项目分析
- Java学生管理系统项目案例
- 【php】9、学生管理系统项目
- 【Java】-小项目-小型学生管理系统
- C语言学生管理系统项目
- ATM监控管理系统测试
- 第一个项目--学生管理系统的一点收获
- 通过学生管理系统项目学到的知识(1)
- 通过学生管理系统项目学到的知识(2)
- Android小项目之学生管理系统(附源码)
- J2EE项目系列(一)--学生管理系统
- C# WindowForm窗体-菜单栏、状态栏设计--(学生管理系统项目)
- 浅谈做的第一个项目学生后台管理系统
- openGl超级宝典学习笔记 (1)第一个三角形
- 各种音视频编解码学习详解
- js 实现的 打字效果(参考网络)
- RabbitMQ 菜鸟安装、RabbitMQ初接触 AMQP 安装、配置指南
- 使用java自带md5加密(转载)
- 6.28 周末 ATM 学生管理系统项目
- linux下c常用debug
- 强连通分量与双连通分量
- 服务器response流程
- 非常感谢这位朋友的博客,网络不好安装erlang成了大问题。
- 七大排序算法总结(含优化)
- JdbcTemplate.queryForList()方法各不同参数的详解
- Java的native关键字
- pthread_once