您的位置:首页 > 健康 > 美食 > C语言实现小区物业管理系统

C语言实现小区物业管理系统

2025/1/7 17:58:58 来源:https://blog.csdn.net/weixin_65589140/article/details/132921901  浏览:    关键词:C语言实现小区物业管理系统

业主信息包括:业主编号、业主名称、业主电话、业主房号,业主单位,用电量、用水量、物业费、水电费。

1业主信息录入、修改、删除功能;

2按照业主编号排序、浏览功能;

3可按业主名称查询,按业主电话查询,按业主房号查询;

4可生成业主缴费清单报表功能。

#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<algorithm>
#define MAXSIZE 100
const double  perwatercost=3;//这里设定水费每吨3元 
const double  pereleccost=0.5;//电费一度0.5元 
typedef struct 
{int id;         //业主编号 char name[100]; //业主名字char phone[100];//业主电话 char num[100];  //业主房号char workplace[100]; //业主单位 double elec;    //用电量 double water;   //用水量 double wuye;    //物业费 double ewc;     //水电费 
}Owner;
typedef struct 
{Owner data[MAXSIZE];int len;//表长 
}SeqList;
void menu();
void Print(SeqList* L);
void toString(SeqList* L,int i);
void Come(SeqList* L);
void Modify(SeqList* L);
void Delete(SeqList* L);
void Sort(SeqList* L);
void Search(SeqList* L);
void Payment(SeqList* L);
void Printcost(SeqList* L,int i);
void PaymentRealize(SeqList* L,int i);
void menu()
{printf("***********小区物业管理系统\n\n");printf("1.业主信息录入\n\n");printf("2.业主信息修改\n\n");printf("3.业主信息删除\n\n");printf("4.业主信息浏览\n\n");printf("5.查询业主信息\n\n");printf("6.生成业主缴费清单报表\n\n");printf("7.按照业主编号进行排序\n\n");printf("0.退出系统\n\n");
}
void Print(SeqList* L)
{if(L->len==0)//判表空 {printf("Empty!\n");return;}int i;printf("\t\t\t\t\t\t业主信息\n");printf("---------------------------------------------------------------------------------------------------------------\n");printf("业主编号\t业主名称\t业主电话\t业主房号\t业主单位\t用电量\t用水量\t物业费\t水电费\t\n");for(i=0;i<L->len;i++){printf("%d\t\t%s\t\t%s\t%s\t\t%s\t%.2lf\t%.2lf\t%.2lf\t%.2lf\n",L->data[i].id,L->data[i].name,L->data[i].phone,L->data[i].num,L->data[i].workplace,L->data[i].elec,L->data[i].water,L->data[i].wuye,L->data[i].ewc);}
}
void Come(SeqList* L)
{printf("请输入业主编号:");scanf("%d",&L->data[L->len].id);printf("请输入业主名称:");scanf("%s",L->data[L->len].name); printf("请输入业主电话:");scanf("%s",L->data[L->len].phone); printf("请输入业主房号:");scanf("%s",L->data[L->len].num); printf("请输入业主单位:");scanf("%s",L->data[L->len].workplace); printf("请输入用水量:");scanf("%lf",&L->data[L->len].water); printf("请输入用电量:");scanf("%lf",&L->data[L->len].elec); printf("请输入物业费:");scanf("%lf",&L->data[L->len].wuye);printf("录入成功!!!\n");L->data[L->len].ewc=perwatercost*L->data[L->len].water+pereleccost*L->data[L->len].elec;//水电费根据用水量和用电量计算得出 L->len++;
}
void Modify(SeqList* L)
{Print(L);printf("\n");if(L->len==0)//判表空 {printf("Empty!\n");return;}printf("您想修改谁的信息呢?请输入该业主名称:");char name1[100];scanf("%s",name1);int id1;         char phone1[100]; char workplace1[100];int m;for(int i=0;i<L->len;i++){if(strcmp(L->data[i].name,name1)==0){printf("请问您想修改该业主的什么信息呢?\n");printf("1.编号\n");printf("2.电话\n");printf("3.单位\n");scanf("%d",&m);switch(m){case 1:printf("请输入修改后的编号:");scanf("%d",&id1);L->data[i].id=id1; break;case 2:printf("请输入修改后的电话:");scanf("%s",phone1);strcpy(L->data[i].phone,phone1); break;case 3:printf("请输入修改后的单位:");scanf("%d",&workplace1);strcpy(L->data[i].workplace,workplace1); break;}printf("修改成功!!!\n");return;}}printf("未查找到该业主,请检查输入!!!\n");
}
void Delete(SeqList* L)
{printf("\n");if(L->len==0)//判表空 {printf("Empty!\n");return;}Print(L);printf("您想删除谁的信息呢?请输入该业主名称:");char name1[10];scanf("%s",name1);for(int i=0;i<L->len;i++){if(strcmp(L->data[i].name,name1)==0){for(int j=i+1;j<L->len;j++){L->data[j-1]=L->data[j];//将要删除位置后面的元素前移 }L->len--;printf("删除成功!!!\n");return; }}printf("未查找到该业主,请检查输入!\n");
}
void Sort(SeqList* L)//冒泡排序升序 
{int i,j;Owner g;for(i=0;i<L->len-1;i++){for(j=i+1;j<L->len;j++){if(L->data[i].id>L->data[j].id){g=L->data[j];L->data[j]=L->data[i];L->data[i]=g;}}}printf("排序成功!!!\n"); Print(L);
}
void toString(SeqList* L,int i)//输出所查找的业主信息 
{printf("您所查找的业主信息:\n");printf("----------------------------------------------------------------------------\n");printf("业主编号\t业主名称\t业主电话\t业主房号\t业主单位\t用电量\t用水量\t物业费\t水电费\t\n");printf("%d\t\t%s\t\t%s\t%s\t\t%s\t%.2lf\t%.2lf\t%.2lf\t%.2lf\n",L->data[i].id,L->data[i].name,L->data[i].phone,L->data[i].num,L->data[i].workplace,L->data[i].elec,L->data[i].water,L->data[i].wuye,L->data[i].ewc);}
void Search(SeqList* L)
{if(L->len==0){printf("Empty!\n");return;}int m;printf("您想通过什么方式查找?\n");printf("1.业主名称\n");printf("2.业主电话\n");printf("3.业主房号\n");char name1[100];char phone1[100];char num1[100];scanf("%d",&m);switch(m){case 1:printf("请输入需要查找的业主名称:");scanf("%s",name1);for(int i=0;i<L->len;i++){if(strcmp(L->data[i].name,name1)==0){toString(L,i);}return;}break;case 2:printf("请输入需要查找的业主电话:");scanf("%s",phone1);for(int i=0;i<L->len;i++){if(strcmp(L->data[i].phone,phone1)==0){toString(L,i);}return;}break;case 3:printf("请输入需要查找的业主房号:");scanf("%s",num1);for(int i=0;i<L->len;i++){if(strcmp(L->data[i].num,num1)==0){toString(L,i); }return;}break;}
}
void Payment(SeqList* L)
{printf("欢迎来到业主缴费功能\n");printf("请输入您的姓名:");char name1[10];scanf("%s",name1);for(int i=0;i<L->len;i++){if(strcmp(L->data[i].name,name1)==0){printf("下面是您的账单明细:\n");Printcost(L,i);PaymentRealize(L,i);return;}}printf("未查找到该业主,请检查输入!\n");
}
void Printcost(SeqList* L,int i)
{printf("--------------------------------\n");printf("业主:%s\n",L->data[i].name);printf("房号:%s\n",L->data[i].num);printf("用水量:%.2lf\n",L->data[i].water); printf("用电量:%.2lf\n",L->data[i].elec);printf("水电费:%.2lf\n",L->data[i].ewc); printf("物业费:%.2lf\n\n",L->data[i].wuye);printf("您目前总共需要缴费金额:%.2lf\n\n",L->data[i].ewc+L->data[i].wuye);printf("--------------------------------\n");
}
void PaymentRealize(SeqList* L,int i)
{int m;do{printf("请缴纳服务费:\n");printf("1.水电费\n");printf("2.物业费\n");printf("0.退出\n");scanf("%d",&m);double cash;if(m==1){printf("请输入要缴纳的金额:");scanf("%lf",&cash);if(L->data[i].ewc>=cash){printf("缴费成功!\n");printf("--------------------------------\n");L->data[i].ewc-=cash;	}else printf("超出金额!请重新操作\n");}else if(m==2){printf("请输入要缴纳的金额:");scanf("%lf",&cash);if(L->data[i].wuye>=cash){printf("缴费成功!\n");printf("--------------------------------\n");L->data[i].wuye-=cash;	}else printf("超出金额!请重新操作\n\n");}}while(m!=0);printf("谢谢您的使用!\n");
}
int main()
{int m;system("color F9");SeqList t={{{1001,"高腾","13891729217","10-0601","西安理工大学",10,10,10,35},{1002,"张铭","13100838756","7-0701","西安**大学",10,100,10,305},{1003,"蒋平","13100717423","8-0822","西安**大学",40,200,20,620},{1007,"王丹","13122717423","6-0822","西安**大学",20,20,35,70},{1006,"邓勇","13132717423","5-0822","西安**大学",20,0,45,10},{1004,"李军","15100717423","10-0822","西安**大学",220,20,120,170},{1009,"赵婧","15100717423","6-0822","西安**大学",210,220,200,765},{1005,"周婷","15100717423","9-0822","西安**大学",10,120,200,365},{1008,"罗燕","18100717423","1-0822","西安**大学",20,320,40,970},{1010,"彭瑞","18100717423","3-0822","西安**大学",10,60,150,185},},10};//初始化10个元素 do{system("cls");menu();printf("请输入你的选择:\n");scanf("%d",&m);switch(m){case 1: Come(&t);//录入 system("pause");break;case 2: Modify(&t);//修改 system("pause"); break;case 3: Delete(&t);//删除 system("pause"); break;case 4: Print(&t);//输出 system("pause"); break;case 5: Search(&t);//查找 system("pause"); break;case 6: Payment(&t);//缴费 system("pause");break;case 7: Sort(&t);//排序 system("pause");break;case 0: printf("感谢您的使用!");//退出 exit(0);default:printf("输入有误!!!请重新输入:\n");system("pause");break;}}while(m!=0);return 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com