c语言大作业,物业管理系统.基本满足大部分的作业需求.代码最后附有代码运行时候需要的数据
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//管理员账号:12345
//管理员密码:12345
//文件名字
/*工程业主信息.txt", );
工程账号密码.txt", );
*/
struct node {
char account[100];//账号
char key[100];//密码
char name[100];//名字
char sex[20];//性别
char Id_card[100];//身份证
char tel_number[100];//电话号码
int building_number;//楼号
int room_number;//房号
int unit_number;//单元号
double square_meter;//平方米数
double square_money;//每平方米价格
double wuye_cost;//应缴物业费
char tips[1000];//备注信息
struct node* next;
};
typedef struct node* Person;
//菜单函数
void menu_main();//主菜单 (完成)
void wuye_menu();//物业菜单 (完成)
void yezu_menu();//业主菜单 (完成)
void menu_change();//修改用户数据菜单(完成)
//物业和业主系统
int wuye_os();//物业系统
int yezu_os();//业主系统 (完成)
//物业系统函数
void add_new();//添加新用户 ,用户填写账号密码 (完成)
void change_one();//修改用户信息 (完成)
void high_fee();//按物业费高低排序 (完成)
void floor_fee();//按照楼层先后排序
void del_one(); //删除用户信息 (完成)
void find_people();//查看用户信息 (完成)
void updata_fee();//更新物业费 (完成)
struct node* creatlist();//链表生成函数(完成)
//业主系统函数
void fee_find(char s[20]); //查找物业费 (完成);
void information_find(char s[20]);//查询个人信息 (完成)
void get_fee(char s[20]);//缴纳物业费 (完成)
int main()
{
Person L = NULL;
menu_main();
int n = 0;
scanf("%d", &n);
switch (n)
{
case 1:
wuye_os();
break;
case 2:
yezu_os();
break;
default:
break;
}
}
int wuye_os()//物业系统
{
int account1 = 12345;
int key1 = 12345;
int s1, s2;
printf("请输入管理员账号密码\n");
printf("账号:");
scanf("%d", &s1);
printf("密码:");
scanf("%d", &s2);
if (s1 == account1 && s2 == key1)
{
wuye_menu();
int ch = 0;
scanf("%d", &ch);
switch (ch)
{
case 1:
add_new();//添加 (完成)
break;
case 2:
change_one();//修改 (完成)
break;
case 3:
high_fee();//欠费多少
break;
case 4:
floor_fee();//楼层排序欠费
break;
case 5:
del_one();//删除信息
break;
case 6:
updata_fee();//更新物业费 (完成)
break;
case 7:
find_people();//查看所有用户信息
break;
case 8:
menu_main();
break;
default:
break;
}
}
else
{
printf("||退出系统||\n");
return 0;
}
}
int yezu_os()//业主系统(完成)
{
printf("请输入账号密码登录系统\n");
char account1[20], key1[20];
char account2[20], key2[20];
int flag = 0, tig = 0;//做标记符号
printf("账号:");
scanf("%s", account1);
printf("密码:");
scanf("%s", key1);
FILE* fp1;
fp1 = fopen("工程账号密码.txt", "r");
if (fp1 == NULL) printf("文件打开失败\n");
while (fscanf(fp1, "%s %s", account2, key2) == 2)
{
if (strcmp(account1, account2) == 0 && strcmp(key1, key2) == 0)
{
printf("输入正确的账号和密码,正常进入系统\n");
flag = 1;
break;
}
}
fclose(fp1);
if (flag == 0)
{
printf("密码或账号错误\n");
}
if (flag == 1)
{
yezu_menu();
int n = 0;
scanf("%d", &n);
switch (n)//查询物业费
{
case 1:
fee_find(account1); //传递业主账号
break;
case 2://查询个人信息
information_find(account1);//传递业主账号
break;
case 3://缴纳物业费
get_fee(account1);//传递业主账号用于进行信息比对
break;
}
}
}
void get_fee(char s[20])//缴纳物业费(完成)
{
fee_find(s);
char ss[20];
strcpy(ss, s);
printf("请输入要缴纳的金额:");
double fee = 0;
scanf("%lf", &fee);
//结构体中的各项数据
char s1[20], s2[20], s3[20], s4[20], s5[20], s6[20];
int s7, s8, s9;
double s10, s11, s12;
char s13[100];
Person p1, head2, head = creatlist();//调用链表创建函数生成信息链表
// 文件
FILE* fp1, * fp2;
fp1 = fopen("工程业主信息.txt", "w");
head2 = head;
double newfee = 0;
int flag = 0;
while (head2 != NULL)
{
//再把链表中的数据存入文件
if (strcmp(head2->account, ss) == 0)//账号比对`
{
newfee = head2->wuye_cost - fee;
fprintf(fp1, "%s %s %s %s %s %s %5d %5d %5d %9.2lf %9.2lf %9.2lf %s\n", head2->account, head2->key, head2->name, head2->sex, head2->Id_card, head2->tel_number, head2->building_number, head2->room_number, head2->unit_number, head2->square_meter, head2->square_money, newfee, head2->tips);
head2 = head2->next;
if (head2 == NULL) break;
}
fprintf(fp1, "%s %s %s %s %s %s %5d %5d %5d %9.2lf %9.2lf %9.2lf %s\n", head2->account, h