当前位置:网站首页>[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 ")
}
边栏推荐
- Image feature SIFT (scale invariant feature transform)
- Natural language processing hanlp
- MySQL 啥时候用表锁,啥时候用行锁?
- Opencv project - credit card recognition (learning record)
- 避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!
- [linear algebra] deeply understand matrix multiplication, symmetric matrix, positive definite matrix
- Detailed notes on pytoch building neural network
- Talk about compilers based on vscode
- 学习笔记总结篇(一)
- Autojs article proficient in detailed explanation of autojs script tutorial
猜你喜欢

赛宁TechTalk丨攻防演练:攻击组合拳 “稳准狠”渗透

Hcip day 8 notes

Digital twin demonstration project -- Talking about simple pendulum (4) IOT exploration
![[matlab] (III) application of MATLAB in Higher Mathematics](/img/ff/72b13fb597d5bdf3a989dd86cb6888.png)
[matlab] (III) application of MATLAB in Higher Mathematics

Anaconda cannot shut down the method of forced shutdown
![[matlab] (IV) application of MATLAB in linear algebra](/img/c8/97fddb4105008990173247b1b4a155.png)
[matlab] (IV) application of MATLAB in linear algebra

Case practice - panoramic image mosaic: feature matching method

Devops essay

Debug NO2 check for errors according to the process

MySQL 啥时候用表锁,啥时候用行锁?
随机推荐
*Code understanding * common function parsing in pytoch
Opencv project - credit card recognition (learning record)
Kubernetes: (I) basic concepts
Opencv project practice - credit card recognition
Arduino's super power-saving sleep mode has worked with one 18650 battery for 17 years
What is NFT? An article to understand the concept of NFT
45. Jumping game II
Hegong sky team vision training day4 - traditional vision, contour recognition
Debug No4 use renderdoc to troubleshoot bugs
App performance test case
[Huawei] Huawei machine test question-105
Hcip 13th day notes
Solve the problem that Anaconda navigator cannot be opened
Workspace creation
我在微软的这六个月
*Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
Typescript double question mark operator
【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵
NFT是什么?一篇文章搞懂NFT的概念
33 introduction to sparksql, dataframe and dataset