C语言 机房收费管理系统
时间: 2023-11-23 08:07:39 浏览: 114
收费管理系统一般包括以下模块:
1. 学生信息管理模块:包括学生基本信息(如学号、姓名、性别、年龄等)和缴费信息(如缴费时间、缴费金额等)的管理。
2. 收费标准管理模块:包括不同收费标准(如学费、住宿费、杂费等)的设定和修改。
3. 收费查询模块:学生和管理员可以查询学生的缴费情况。
4. 缴费模块:学生可以在系统中缴纳学费、住宿费等。
下面是一个简单的 C 语言实现的机房收费管理系统的示例:
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENT_NUM 100 // 最大学生数量
typedef struct Student {
char id[20]; // 学号
char name[20]; // 姓名
int age; // 年龄
char gender[10]; // 性别
float tuition; // 学费
float accommodation; // 住宿费
float miscellaneous; // 杂费
float total; // 总费用
} Student;
Student students[MAX_STUDENT_NUM]; // 学生数组
int student_count = 0; // 学生数量
// 显示主菜单
void show_menu() {
printf("*********************************\n");
printf("* 1. 添加学生信息 *\n");
printf("* 2. 显示学生信息 *\n");
printf("* 3. 修改学生信息 *\n");
printf("* 4. 删除学生信息 *\n");
printf("* 5. 查询学生缴费情况 *\n");
printf("* 6. 缴纳学费 *\n");
printf("* 7. 缴纳住宿费 *\n");
printf("* 8. 缴纳杂费 *\n");
printf("* 9. 退出系统 *\n");
printf("*********************************\n");
}
// 添加学生信息
void add_student() {
if (student_count >= MAX_STUDENT_NUM) {
printf("学生数量已达到上限,无法添加新的学生!\n");
return;
}
Student student;
printf("请输入学生学号:");
scanf("%s", student.id);
printf("请输入学生姓名:");
scanf("%s", student.name);
printf("请输入学生年龄:");
scanf("%d", &student.age);
printf("请输入学生性别:");
scanf("%s", student.gender);
student.tuition = 0;
student.accommodation = 0;
student.miscellaneous = 0;
student.total = 0;
students[student_count] = student;
student_count++;
printf("学生信息添加成功!\n");
}
// 显示学生信息
void show_students() {
if (student_count == 0) {
printf("暂无学生信息!\n");
return;
}
printf("学号\t姓名\t年龄\t性别\t学费\t住宿费\t杂费\t总费用\n");
for (int i = 0; i < student_count; i++) {
Student student = students[i];
printf("%s\t%s\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n", student.id, student.name, student.age,
student.gender, student.tuition, student.accommodation, student.miscellaneous, student.total);
}
}
// 修改学生信息
void modify_student() {
char id[20];
printf("请输入要修改的学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
printf("请输入学生姓名:");
scanf("%s", student->name);
printf("请输入学生年龄:");
scanf("%d", &student->age);
printf("请输入学生性别:");
scanf("%s", student->gender);
printf("学生信息修改成功!\n");
return;
}
}
printf("找不到对应的学生信息!\n");
}
// 删除学生信息
void delete_student() {
char id[20];
printf("请输入要删除的学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
for (int j = i; j < student_count - 1; j++) {
students[j] = students[j + 1];
}
student_count--;
printf("学生信息删除成功!\n");
return;
}
}
printf("找不到对应的学生信息!\n");
}
// 查询学生缴费情况
void query_payment() {
char id[20];
printf("请输入要查询的学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
printf("学号\t姓名\t缴费时间\t学费\t住宿费\t杂费\n");
printf("%s\t%s\t--\t%.2f\t%.2f\t%.2f\n", student->id, student->name,
student->tuition, student->accommodation, student->miscellaneous);
return;
}
}
printf("找不到对应的学生信息!\n");
}
// 缴纳学费
void pay_tuition() {
char id[20];
printf("请输入学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
float tuition;
printf("请输入学费金额:");
scanf("%f", &tuition);
student->tuition += tuition;
student->total += tuition;
printf("学费缴纳成功!\n");
return;
}
}
printf("找不到对应的学生信息!\n");
}
// 缴纳住宿费
void pay_accommodation() {
char id[20];
printf("请输入学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
float accommodation;
printf("请输入住宿费金额:");
scanf("%f", &accommodation);
student->accommodation += accommodation;
student->total += accommodation;
printf("住宿费缴纳成功!\n");
return;
}
}
printf("找不到对应的学生信息!\n");
}
// 缴纳杂费
void pay_miscellaneous() {
char id[20];
printf("请输入学生学号:");
scanf("%s", id);
for (int i = 0; i < student_count; i++) {
Student *student = &students[i];
if (strcmp(student->id, id) == 0) {
float miscellaneous;
printf("请输入杂费金额:");
scanf("%f", &miscellaneous);
student->miscellaneous += miscellaneous;
student->total += miscellaneous;
printf("杂费缴纳成功!\n");
return;
}
}
printf("找不到对应的学生信息!\n");
}
int main() {
while (1) {
show_menu();
int choice;
printf("请选择操作:");
scanf("%d", &choice);
switch (choice) {
case 1:
add_student();
break;
case 2:
show_students();
break;
case 3:
modify_student();
break;
case 4:
delete_student();
break;
case 5:
query_payment();
break;
case 6:
pay_tuition();
break;
case 7:
pay_accommodation();
break;
case 8:
pay_miscellaneous();
break;
case 9:
printf("感谢使用本系统!\n");
exit(0);
default:
printf("输入错误,请重新选择操作!\n");
}
}
return 0;
}
```
该示例实现了添加、显示、修改、删除学生信息,查询学生缴费情况,以及缴纳学费、住宿费、杂费等功能。需要注意的是,上述示例仅为演示用途,实际使用中还需要根据具体需求进行修改和完善。
阅读全文