电煤气管理系统c++源代码.docx
《电煤气管理系统c++源代码.docx》由会员分享,可在线阅读,更多相关《电煤气管理系统c++源代码.docx(28页珍藏版)》请在冰豆网上搜索。
![电煤气管理系统c++源代码.docx](https://file1.bdocx.com/fileroot1/2022-10/29/02fea817-e01e-47b4-ae17-c19cfd2eff0c/02fea817-e01e-47b4-ae17-c19cfd2eff0c1.gif)
电煤气管理系统c++源代码
#include"iostream"
#include"string"
#include"cstdlib"
#include"iomanip"
#include"fstream"
usingnamespacestd;
intns,nt;
classFeebz//学生的信息类
{
public:
Feebz(stringNum="0904032011",stringName="任家双",doublewater=1,doublepower=0,doublegas=10);//构造函数
friendostream&operator<<(ostream&out,Feebz&r)//运算符重载
{out<out<out<out<out<out<out<out<out<if(r.flag)
out<<"已交";
else
out<<"未交";
returnout;
}
voidoperator=(Feebzr);//运算符重载
doubleGetW();//计算学生水费
doubleGetP();//计算学生电费
doubleGetG();//计算学生气费
doubleGetTotal(){returnGetW()+GetP()+GetG();}//计算学生总费用
stringnumber,name;
intflag;
doublewater,power,gas,Waterprice,Powerprice,Gasprice;
};
Feebz:
:
Feebz(stringNum,stringName,doubleWater,doublePower,doubleGas)//构造函数
{number=Num;
name=Name;
water=Water;
power=Power;
gas=Gas;
flag=0;
}
voidFeebz:
:
operator=(Feebzr)//赋值运算符重载
{name=r.name;
number=r.number;
water=r.water;
power=r.power;
gas=r.gas;
}
doubleFeebz:
:
GetW()//计算学生水费
{
if(water<=6)
Waterprice=0;
else
Waterprice=0.6*(water-6);
returnWaterprice;
}
doubleFeebz:
:
GetP()//计算学生电费
{if(power<=6)
Powerprice=0;
else
Powerprice=0.6*(power-6);
returnPowerprice;
}
doubleFeebz:
:
GetG()//计算学生气费
{if(gas<=6)
Powerprice=0;
else
Powerprice=0.6*(gas-6);
returnPowerprice;
}
classStuMan//学生管理类
{public:
StuMan(intsz=50){size=sz;St=newFeebz[size];}//构造函数
~StuMan(){delete[]St;}//析构函数
voidMainMenu();//主菜单
voidFeeMenu();//学生交费菜单
voidNumFee();//输入学号交费
voidNameFee();//输入姓名交费
voidCheckMenu();//学生查询菜单
voidNumCheck();//输入学号查询
voidNameCheck();//输入姓名查询
voidAdd();//增加学生功能
voidDeleteMenu();//学生删除菜单
voidNumDelete();//输入学号删除
voidNameDelete();//输入姓名删除
voidRegist();
voidChakan();//学生查看作用
private:
intsize;
Feebz*St;
};
voidStuMan:
:
MainMenu()//主菜单
{system("cls");
intchoice;
cout<<"*************************************"<cout<<"欢迎使用学生水电气费管理系统"<cout<<"1.缴纳水电气费"<cout<<"2.查询一个同学水电气费用量"<cout<<"3.查看所有同学的缴费情况"<cout<<"4.增加学生信息"<cout<<"5.删除学生信息"<cout<<"6.退出系统"<cout<<"*************************************"<while
(1)
{
cout<<"请选择:
";
cin>>choice;
switch(choice)
{case1:
FeeMenu();break;
case2:
CheckMenu();break;
case3:
Chakan();break;
case4:
Add();break;
case5:
DeleteMenu();break;
default:
break;
}if(choice==6)break;}
}
voidStuMan:
:
Regist()
{inti=0;
ifstreamtfile("student.txt");
while(tfile.good())
{
tfile>>St[i].number;
tfile>>St[i].name;
tfile>>St[i].water;
tfile>>St[i].power;
tfile>>St[i].gas;
i++;
}
tfile.close();
ns=i;
}
voidStuMan:
:
FeeMenu()//学生交费菜单
{system("cls");
intchoice;
cout<<"********************"<cout<<"学生交费菜单"<cout<<"1.按照学号交费"<cout<<"2.按照姓名交费"<cout<<"3.返回主菜单"<cout<<"4.退出系统"<cout<<"********************"<while
(1)
{
cout<<"请选择:
";
cin>>choice;
switch(choice)
{
case1:
NumFee();break;
case2:
NameFee();break;
case3:
system("cls");
MainMenu();break;
default:
exit
(1);
}
if(choice==3)break;
}
}
voidStuMan:
:
NumFee()//输入学号交费
{stringnumber;
floatmoney;
intflag=0,flag1=0;
cout<<"欢迎使用交费功能"<cout<<"请输入学生学号:
";
cin>>number;
for(inti=0;iif(number==St[i].number)
{flag1=1;
cout<<"该同学应该交费共"<cout<<"该同学实际交钱:
";
cin>>money;
if(money{cout<<"该同学需再补交"<St[i].flag=0;
MainMenu();
}
else
{cout<<"该同学交费成功,且找零钱为"<St[i].flag=1;
MainMenu();
}break;
}
if(!
flag1)
{system("cls");
cout<<"该学生的学号输入错误,请重新使用该功能!
"<NumFee();
}
}
voidStuMan:
:
NameFee()//输入姓名交费
{stringname;
floatmoney;
intflag=0,flag1=0;
cout<<"欢迎使用交费功能"<cout<<"请输入学生姓名:
";
cin>>name;
for(inti=0;iif(name==St[i].name)
{flag1=1;
cout<<"该同学应该交费共"<cout<<"该同学实际交钱:
";
cin>>money;
if(money{cout<<"该同学需再补交"<St[i].flag=0;
MainMenu();
}
else
{cout<<"该同学交费成功,且找零钱为"<St[i].flag=1;
MainMenu();
}break;
}
if(!
flag1)
{system("cls");
cout<<"该学生的姓名输入错误,请重新使用该功能!
"<NameFee();
}
}
voidStuMan:
:
CheckMenu()//学生查询菜单
{system("cls");
intchoice;
cout<<"********************"<cout<<"学生查询菜单"<cout<<"1.按照学号查询"<cout<<"2.按照姓名查询"<cout<<"3.返回主菜单"<cout<<"4.退出系统"<co