当前位置:网站首页>[golang from introduction to practice] student achievement management system
[golang from introduction to practice] student achievement management system
2022-07-24 08:01:00 【A programmer who can vibrate knives】
Student achievement management system
Function is introduced
1、 Student achievement system increases
2、 Student achievement system delete
3、 Student achievement system query
4、 Student achievement system modification
5、 Student achievement system information acquisition
Effect display
golang Student achievement management system
Programming ideas
1、 Defining structure : Store the information of each student as a group
2、 Define an array : Store student information structures
Design : All functions of the system operate around arrays and structures
Related knowledge
Array 、 Structure 、for loop 、goto Jump 、if Conditional statements 、 Output input function
Source code
package main
import (
"fmt"
)
var studb []stu_msg
const screen = `1、 Add student grades 2、 Delete student grades 3、 Revise student grades 4、 Check student grades 5、 Get student grades 6、 sign out `
var n string
type stu_msg struct {
stuid int
name string
math int
english int
golang int
}
func main() {
for {
fmt.Println(screen)
fmt.Print(" Please enter your choice :")
fmt.Scan(&n)
switch n {
case "1":
var stu stu_msg
fmt.Print(" Please enter id:")
fmt.Scan(&stu.stuid)
fmt.Print(" Please enter a name :")
fmt.Scan(&stu.name)
fmt.Print(" Please enter the math :")
fmt.Scan(&stu.math)
fmt.Print(" Please input English :")
fmt.Scan(&stu.english)
fmt.Print(" Please enter golang:")
fmt.Scan(&stu.golang)
studb = append(studb, stu)
fmt.Println(" Add success ")
case "2":
var id int
fmt.Print(" Please enter the name of the student to delete ID:")
fmt.Scan(&id)
i := 1
for index, v := range studb {
if v.stuid == id {
studb = append(studb[:index], studb[index+1:]...)
fmt.Println(" Delete successful ")
break
}
if i == len(studb) {
fmt.Println(" This student was not found !")
}
i++
}
case "3":
var id int
fmt.Print(" Please enter the name of the student you want to modify ID:")
fmt.Scan(&id)
i := 1
for index, v := range studb {
if v.stuid == id {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
fmt.Print(" Please enter a name :")
fmt.Scan(&studb[index].name)
fmt.Print(" Please enter the math :")
fmt.Scan(&studb[index].math)
fmt.Print(" Please input English :")
fmt.Scan(&studb[index].english)
fmt.Print(" Please enter golang:")
fmt.Scan(&studb[index].golang)
fmt.Println(" Modification successful ")
break
} else if i == len(studb) {
fmt.Println(" This student was not found !")
}
i++
}
case "4":
var name string
fmt.Print(" Please enter the name of the student you want to query :")
fmt.Scan(&name)
i := 1
for _, v := range studb {
if v.name == name {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
break
} else if i == len(studb) {
fmt.Println(" This student was not found !")
}
i++
}
case "5":
for _, v := range studb {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
}
case "6":
goto end
}
}
end:
fmt.Println(" Quit successfully ")
}
边栏推荐
- Tools for data visualization
- News topic classification task -- tochtext library for text classification
- The vision group of Hegong University Sky team trained day3 - machine learning, strengthened the use of Yolo models, and learned pumpkin books and watermelon books
- 【MATLAB】(三)MATLAB在高等数学中的应用
- Opencv project - credit card recognition (learning record)
- abstract class
- Intelligent robot and intelligent system (Professor Zhengzheng of Dalian University of Technology) -- 5. Bionic robot
- What is NFT? An article to understand the concept of NFT
- 生成模型与判别模型
- Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
猜你喜欢

Debug No4 use renderdoc to troubleshoot bugs

Collection of linked list topics

Opencv project - credit card recognition (learning record)

Do you want to have a robot that can make cartoon avatars in three steps?

DevOps随笔

Robert operator, Sobel operator, Laplace operator

Hegong sky team vision training Day2 - traditional vision, opencv basic operation

MS SQL Server 2019 学习

rbm 对比散度

OpenGL camera and periodic review
随机推荐
hcip第八天笔记
MySQL 啥时候用表锁,啥时候用行锁?
MS SQL Server 2019 学习
QT | string generation QR code function
Collection of binary tree topics
Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
Solve the problem that Anaconda navigator cannot be opened
Project practice - document scanning OCR recognition
mysql使用explain分析sql执行计划帮助查找性能瓶颈
Kubernetes: (I) basic concepts
Summary of study notes (I)
The difference between online learning and offline learning
Debug NO2 check for errors according to the process
Debug No3 multi texture overlay
Stable TTL serial port rate supported by Arduino under different dominant frequencies
Debug No1 summarizes common solutions to bugs
学习笔记总结篇(一)
加密熊市:有人大举扩张 有人裁员收缩
Installation and use of CONDA
abstract class