既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
System.out.println("\t\t\t+ 1 录入成绩 +");
System.out.println("\t\t\t+ 2 查询成绩 +");
System.out.println("\t\t\t+ 3 输出成绩 +");
System.out.println("请输入0-3:");
a=in.nextInt();
switch(a) {
case 0:
System.out.println("退出成功!");
break;
case 1:
new Input();
break;
case 2:
new Seeknum();
break;
case 3:
new Outnum();
break;
default:
System.out.println("输入有误!");
break;
}
}
}
public static void main(String[] args) {
new Main();
}
}
package kechengsheji;
import java.sql.*;
public class SQL {
Connection conn;
public Connection getConn() {
try {
Class.forName(“com.mysql.cj.jdbc.Driver”);
String url="jdbc:mysql://localhost:3306/swy"
+ "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false"; //JDBC的URL
conn = DriverManager.getConnection(url, "root","266531"); //建立数据库连接,获得连接对象conn
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) {
System.out.println("hello world!");
}
}
package kechengsheji;
import java.util.Scanner;
import java.sql.*;
import kechengsheji.SQL;
public class Input {
private String b,c;
private double d,e,f,g;
private double sum,aver;
Scanner in=new Scanner(System.in);
private int a=2;
Input(){
while(a!=0) {
System.out.println(“+++++++++++++++++++++”);
System.out.println(“+ 1 录入成绩 +”);
System.out.println(“+ 0 返回 +”);
a=in.nextInt();
switch (a) {
case 0:
System.out.println(“返回成功!”);
break;
case 1:
System.out.println(“请输入学生姓名:”);
b=in.next();
System.out.println(“请输入学生学号:”);
c=in.next();
System.out.println(“请输入学生应用数学成绩:”);
d=in.nextDouble();
System.out.println(“请输入学生大学英语成绩:”);
e=in.nextDouble();
System.out.println(“请输入学生Java程序设计成绩:”);
f=in.nextDouble();
System.out.println(“请输入学生计算机应用基础成绩:”);
g=in.nextDouble();
sum=d+e+f+g; //总成绩
aver=sum/4; //平均成绩
//数据库
SQL bd=new SQL();
Connection conn=bd.getConn();
try {
Statement stmt = conn.createStatement(); //创建Statement对象
try {
String sql = “insert into students values(?,?,?,?,?,?,?,?)”; //要执行的SQL
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(1,b); //传入带占位符的SQL语句
pst.setString(2,c);
pst.setDouble(3,d);
pst.setDouble(4,e);
pst.setDouble(5,f);
pst.setDouble(6,g);
pst.setDouble(7,sum);
pst.setDouble(8,aver);
pst.executeUpdate(); //执行 update和insert、delete等sql语句
System.out.println(“保存成功!”);
pst.close();
}catch(SQLIntegrityConstraintViolationException e) {
System.out.println(“该学生已存在!”);
}
stmt.close();
conn.close();
}catch(SQLException e){
e.printStackTrace();
}
//数据库
break;
default:
System.out.println(“输入错误!”);
}
}
}
public static void main(String[] args) {
new Input();
}
}
package kechengsheji;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import kechengsheji.SQL;;
public class Seeknum {
private String num,nam;
int i=0;
Seeknum(){
Scanner s1 =new Scanner(System.in);
int a = 3;
while(a!=0){
System.out.println(“*********************”);//查找界面并选择
System.out.println(“* 0 返回 *”);
System.out.println(“* 1 查询成绩 *”);
System.out.println(“请输入0或1:”);
a =s1.nextInt();
switch (a) {
case 0:
System.out.println(“返回成功!”);
break;
case 1:
//数据库
SQL bd=new SQL();
Connection conn=bd.getConn();
try {
System.out.println(“请输入姓名:”);
nam=s1.next();
Statement stmt = conn.createStatement(); //创建Statement对象
String sql = “select * from students;”; //要执行的SQL
ResultSet rs = stmt.executeQuery(sql);//创建数据对象,产生单个结果集的语句
while(rs.next()) {
if(rs.getString(“name”).equals(nam)) {
i=1;
System.out.println(“成绩如下:”);
//从数据库查找成绩
System.out.println();
System.out.println(“姓名:”+rs.getString(1) );
System.out.println(“学号:” +rs.getString(2) );
System.out.println(“应用数学:” +rs.getDouble(3) );
System.out.println(“大学英语 :” +rs.getDouble(4) );
System.out.println(“java程序设计:” +rs.getDouble(5) );
System.out.println(“计算机应用基础:” +rs.getDouble(6) );
System.out.println(“总分:” +rs.getDouble(7) );
System.out.println(“平均分:” +rs.getDouble(8) );
System.out.println();
//数据库
break;
}
}
if(i==0)
System.out.println("暂无该学生成绩!");
rs.close();
stmt.close();
conn.close();
}catch (SQLException e) {
e.printStackTrace();
}
break;
default:
System.out.println("输入有误!");
break;
}
}
}
public static void main(String[] args){
new Seeknum();
}
}
package kechengsheji;
import kechengsheji.paiming;
import kechengsheji.kemuchengji;
import java.util.Scanner;
import java.sql.*;
public class Outnum {
Scanner in=new Scanner(System.in);
private int a=3;
Outnum(){
while(a!=0){
System.out.println(“+++++++++++++++++++”);
System.out.println(“+ 1 排名 +”);
System.out.println(“+ 2 科目成绩 +”);
System.out.println(“+ 0 返回 +”);
System.out.println(“请输入0-2:”);
a=in.nextInt();
switch(a) {
case 0:
System.out.println(“返回成功!”);
System.out.println();
break;
case 1:
new paiming();
break;
case 2:
new kemuchengji();
break;
default:
System.out.println(“输入有误!”);
}
}
}
public static void main(String[] args) {
new Outnum();
}
}
package kechengsheji;
import java.sql.*;
public class paiming {
SQL bd=new SQL();
Connection conn=bd.getConn();
private int a=1;
paiming(){
try {
//数据库
Statement stmt;
stmt = conn.createStatement();
String sql=“select name,num,average from students order by average desc;”;
ResultSet rs = stmt.executeQuery(sql);
System.out.println();
System.out.println(“排名”+“\t”+“姓名”+“\t”+" 学号"+“\t\t”+“平均成绩”);
while(rs.next()) {
System.out.println(a+“\t”+rs.getString(“name”)+“\t”+rs.getString(“num”)+“\t\t”+rs.getDouble(“average”));
a++;
}
rs.close();
stmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new paiming();
}
}
package kechengsheji;
import java.sql.*;
import kechengsheji.SQL;
public class kemuchengji {
private double sum,max,min;
SQL bd=new SQL();
Connection conn=bd.getConn();
kemuchengji(){
System.out.println();
System.out.println(“\t\t”+“平均成绩”+“\t\t”+“最高成绩”+“\t\t”+“最低成绩”);
try {
Statement stmt = conn.createStatement(); //创建Statement对象
int i=0;
String sql = “select math from students order by math desc;”; //要执行的SQL
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
sum=sum+rs.getDouble(“math”);
i++;
if(rs.isFirst())
max=rs.getDouble(“math”);
if(rs.isLast())
min=rs.getDouble(“math”);
}
sum=sum/i;//平均成绩
System.out.println(“应用数学成绩: \t”+String.format(“%.2f”, sum)+“\t\t”+max+“\t\t”+min);
i=0;
sum=0.0;
String sql1 = "select English from students order by English desc;"; //要执行的SQL
ResultSet rs1 = stmt.executeQuery(sql1);
while(rs1.next()) {
sum=sum+rs1.getDouble("English");
i++;
if(rs1.isFirst())
max=rs1.getDouble("English");
if(rs1.isLast())
min=rs1.getDouble("English");
}
sum=sum/i; //平均成绩
System.out.println("大学英语成绩: \t"+String.format("%.2f", sum)+"\t\t"+max+"\t\t"+min);
i=0;
sum=0.0;
//数据库
String sql2 = "select Java from students order by Java desc;"; //要执行的SQL
ResultSet rs2 = stmt.executeQuery(sql2);
while(rs2.next()) {
sum=sum+rs2.getDouble("Java");
i++;
if(rs2.isFirst())
max=rs2.getDouble("Java");
if(rs2.isLast())
min=rs2.getDouble("Java");
}
sum=sum/i;//平均成绩
System.out.println("Java程序设计成绩: "+String.format("%.2f", sum)+"\t\t"+max+"\t\t"+min);
i=0;
sum=0.0;
String sql3 = "select computer from students order by computer desc;"; //要执行的SQL
ResultSet rs3 = stmt.executeQuery(sql3);
while(rs3.next()) {
sum=sum+rs3.getDouble("computer");
i++;
if(rs3.isFirst())
max=rs3.getDouble("computer");
if(rs3.isLast())
min=rs3.getDouble("computer");
}
sum=sum/i; //平均成绩
System.out.println("计算机应用基础成绩:"+String.format("%.2f", sum)+"\t\t"+max+"\t\t"+min);
System.out.println();
rs.close();
rs1.close();
rs2.close();
rs3.close();
stmt.close();
conn.close();
}catch(SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new kemuchengji();
}
}
#### 4.结果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200718140400473.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N3eTY2,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200718140440195.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N3eTY2,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200718140525420.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N3eTY2,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200718140557409.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N3eTY2,size_16,color_FFFFFF,t_70)
#### 5.采用GUI界面
**源代码**
package kechengsheji;
import java.awt.*;
import java.awt.event.*;
import javax.sql.rowset.serial.SerialArray;
public class GUImain extends Frame implements ActionListener{
private Button b1,b2,b3,b4;
private Label a1,a2;
private GridBagLayout gb;
private GridBagConstraints gbc;
private GUImain(){
a1=new Label(" 欢迎使用学生成绩管理系统");
a1.setFont(new Font(null,Font.LAYOUT_RIGHT_TO_LEFT,20));
a2=new Label(" ");
gb=new GridBagLayout(); //初始化 gb
setLayout(gb); //设置窗口布局管理器 gb
gbc=new GridBagConstraints(); //初始化网格包容器
b1=new Button(“输入成绩”); //初始化按钮 btn1
b2=new Button(“查询成绩”);
b3=new Button(“输出成绩”);
b4=new Button(“退出系统”);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
dispose();
System.exit(0); //程序退出
}
});
gbc.fill=GridBagConstraints.HORIZONTAL; //设置 gbc 的 fill 域
addComponent(a1,0, 2, 1, 4);
addComponent(a2,4, 2, 1, 2);
addComponent(b1,6, 2, 1, 2);
addComponent(b2,8, 2, 1, 2);
addComponent(b3,10, 2, 1, 2);
addComponent(b4,12, 2, 1, 2);
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand()“输入成绩”) {
GUIinput mygb =new GUIinput();
mygb.setSize(600,400);
mygb.setVisible(true);
}else if(e.getActionCommand()“查询成绩”) {
GUISeeknum mygb =new GUISeeknum();
mygb.setSize(600,400);
mygb.setVisible(true);
}else if(e.getActionCommand()“输出成绩”) {
GUIOutnum mygb=new GUIOutnum();
mygb.setSize(700,500);
mygb.setVisible(true);
}else if(e.getActionCommand()“退出系统”) {
setVisible(false);
dispose();
System.exit(0);
}
}
public void addComponent(Component c,int row,int col, int nrow,int ncol){
gbc.gridx=col; //设置组件显示区域的开始边单元格
gbc.gridy=row; //设置组件显示区域的顶端单元格
gbc.gridheight=ncol; //设置组件显示区域一列的单元格数
gbc.gridwidth=nrow; //设置组件显示区域一行的单元格数
gb.setConstraints(c,gbc); //设置布局的约束条件
add©; //组件 c 添加到容器中
}
public static void main(String[] args) {
GUImain mygb =new GUImain();
mygb.setSize(700,500);
mygb.setVisible(true);
}
}
package kechengsheji;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
import java.sql.*;
import kechengsheji.SQL;
public class GUIinput extends Frame implements ActionListener{
Frame my;
private int a=0;
private Label l1,l2,l3,l4,l5,l6;
private TextField tf1,tf2,tf3,tf4,tf5,tf6;
private Button btn1,btn2,b1;
private GridBagLayout gb;
private GridBagConstraints gbc;
private String a1,a2;
private double a3,a4,a5,a6,sum,aver;
public GUIinput() {
l1=new Label("姓名 ");
l2=new Label("学号 ");
l3=new Label("应用数学 ");
l4=new Label("大学英语 ");
l5=new Label("Java程序设计 ");
l6=new Label(“计算机应用基础”);
tf1=new TextField(20);
tf2=new TextField(20);
tf3=new TextField(20);
tf4=new TextField(20);
tf5=new TextField(20);
tf6=new TextField(20);
gb=new GridBagLayout(); //初始化 gb
setLayout(gb); //设置窗口布局管理器 gb
gbc=new GridBagConstraints(); //初始化网格包容器
btn1=new Button(“提交”); //初始化按钮 btn1
btn2=new Button(“退出”);
btn1.addActionListener(this);
btn2.addActionListener(this);
Panel p0 = new Panel(); //创建,并初始化面板 p1
p0.add(btn1);
p0.add(btn2);
Panel p1 = new Panel();
p1.add(l1);
p1.add(tf1);
Panel p2 = new Panel();
p2.add(l2);
p2.add(tf2);
Panel p3 = new Panel();
p3.add(l3);
p3.add(tf3);
Panel p4 = new Panel();
p4.add(l4);
p4.add(tf4);
Panel p5 = new Panel();
p5.add(l5);
p5.add(tf5);
Panel p6 = new Panel();
p6.add(l6);
p6.add(tf6);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
dispose();
System.exit(0); //程序退出
}
});
gbc.fill=GridBagConstraints.HORIZONTAL; //设置 gbc 的 fill 域
addComponent(p1,0, 2, 1, 1);
addComponent(p2,2, 2, 1, 1);
addComponent(p3,3, 2, 1, 1);
addComponent(p4,4, 2, 1, 1);
addComponent(p5,5, 2, 1, 1);
addComponent(p6,6, 2, 1, 1);
addComponent(p0,9, 2, 1, 1);
}
//********************************************************************************8
public void gui() {
my=new Frame();
my.setBounds(300,300,350,250);
my.setLayout(null);
my.setVisible(true);
b1=new Button(“返回”);
b1.addActionListener(this);
Label a1=new Label(“该学生已存在! “);
Label a2=new Label(“添加成功!”);
Label a3=new Label(“输入为空!”);
if(a1) {
my.add(a1);
a1.setBounds(140,100,100,40);
}
else if(a0) {
my.add(a2);
a2.setBounds(140,100,100,40);
}
else if(a==2) {
my.add(a3);
a3.setBounds(140,100,100,40);
}
my.add(b1);
b1.setBounds(230,190,80,30);
my.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
my.setVisible(false);
my.dispose();
}
});
}
//******************************************************************************************************
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btn1) {
a1=tf1.getText();
if(a1.equals(””))
a=2;
else {
a=0;
a2=tf2.getText();
a3=Double.parseDouble(tf3.getText() );
a4=Double.parseDouble(tf4.getText() );
a5=Double.parseDouble(tf5.getText() );
a6=Double.parseDouble(tf5.getText() );
sum=a3+a4+a5+a6; //总成绩
aver=sum/4; //平均成绩
SQL bd=new SQL();
Connection conn=bd.getConn();
try {
Statement stmt = conn.createStatement(); //创建Statement对象
try {
String sql = "insert into students values(?,?,?,?,?,?,?,?)"; //要执行的SQL
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(1,a1); //传入带占位符的SQL语句
pst.setString(2,a2);
pst.setDouble(3,a3);
pst.setDouble(4,a4);
pst.setDouble(5,a5);
pst.setDouble(6,a6);
pst.setDouble(7,sum);
pst.setDouble(8,aver);
pst.executeUpdate(); //执行 update和insert、delete等sql语句
pst.close();
}catch(SQLIntegrityConstraintViolationException e1) {
a=1;
}
stmt.close();
conn.close();
}catch(SQLException e2){
e2.printStackTrace();
}
}
gui();
}else if(e.getSource()==btn2) {
setVisible(false);
dispose();
}else if(e.getSource()==b1) {
my.setVisible(false);
my.dispose();
}
}
//*******************************************************************************************
public void addComponent(Component c,int row,int col, int nrow,int ncol){
gbc.gridx=col; //设置组件显示区域的开始边单元格
gbc.gridy=row; //设置组件显示区域的顶端单元格
gbc.gridheight=ncol; //设置组件显示区域一列的单元格数
gbc.gridwidth=nrow; //设置组件显示区域一行的单元格数
gb.setConstraints(c,gbc); //设置布局的约束条件
add©; //组件 c 添加到容器中
}
//******************************入口***********************************************************
public static void main(String[] args) {
GUIinput mygb =new GUIinput();
mygb.setSize(600,400);
mygb.setVisible(true);
}
}
package kechengsheji;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import kechengsheji.SQL;
public class GUISeeknum extends Frame implements ActionListener{
Frame my;
String b;
private Label a1;
private Button b1,b2;
private TextField c1;
private GridBagLayout gb;
private GridBagConstraints gbc;
public GUISeeknum() {
a1=new Label("请输入学生姓名: ");
c1=new TextField(20);
gb=new GridBagLayout(); //初始化 gb
setLayout(gb); //设置窗口布局管理器 gb
gbc=new GridBagConstraints(); //初始化网格包容器
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
ublic class GUISeeknum extends Frame implements ActionListener{
Frame my;
String b;
private Label a1;
private Button b1,b2;
private TextField c1;
private GridBagLayout gb;
private GridBagConstraints gbc;
public GUISeeknum() {
a1=new Label("请输入学生姓名: ");
c1=new TextField(20);
gb=new GridBagLayout(); //初始化 gb
setLayout(gb); //设置窗口布局管理器 gb
gbc=new GridBagConstraints(); //初始化网格包容器
[外链图片转存中…(img-6WViKXfp-1715715205472)]
[外链图片转存中…(img-2JNAZFwl-1715715205473)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新