資源簡(jiǎn)介
大一c++課程設(shè)計(jì)中的電煤氣管理系統(tǒng)
這是關(guān)于高校電煤氣管理系統(tǒng)的c++源代碼

代碼片段和文件信息
#include?“iostream“
#include“string“
#include“fstream“
#include“iomanip“
using?namespace?std;
int?count1=0count11=0;??//學(xué)生總數(shù)和交錢的人數(shù)
int?count2=0count22=0;
class?Stu
{
public:
Stu(double?xwater=0double?xpower=0double?xgas=0string?xnum=“a“string?xna=“a“);???//學(xué)生類構(gòu)造函數(shù)
????void??operator??=(Stu?S);???//賦值運(yùn)算符重載??????????????????????????????????????
??? friend??ostream?&operator?<<(ostream?&?aStu?&S)???//插入運(yùn)算符重載
{ a< ? a< ? a< ? a< ? a< ? a< ? a< ? a< ? a< ??????????if(S.flag)
??????????????a<<“已交“;
???????????????else?a<<“未交“;?
???????????????cout< ???????????????return?a; }
?
?double?SGetW();????????//計(jì)算水費(fèi)
???double?SGetC();????????//計(jì)算電費(fèi)
???????double?SGetG();???????//計(jì)算煤氣費(fèi)
???????double?Stotal();?//計(jì)算總費(fèi)用
???????double?waterpowergaswater_ratecircuitgas_ratetotal;
???int?flag;
???string?numbername;
};
?Stu::Stu(double?xwaterdouble?xpowerdouble?xgasstring?xnumstring?xna)??//學(xué)生類構(gòu)造函數(shù)
?{
water=xwater;power=xpower;gas=xgas;
????????number=xnum;name=xna;
????????flag=0;
}
void?Stu::operator??=(Stu??S)?????????//賦值運(yùn)算符重載
? {
? name=S.name;
? number=S.number;
? water=S.water;
? power=S.power;
? gas=S.gas;
?
? }
?
double??Stu::SGetW(?)???????//計(jì)算水費(fèi)
{
if(water<10)?
?????water_rate=0;
else???
???????water_rate=4.2*(water-10);
??return???water_rate;
}
double??Stu::SGetC()??????//計(jì)算電費(fèi)
{
if(power<10)?
?????circuit=0;
else
???????circuit=0.6*(power-10);??
return?circuit;
}?
double?Stu::SGetG()??????????//計(jì)算煤氣費(fèi)
{
if(gas<10)
????gas_rate=0;
else
???gas_rate=2.3*(gas-10);????
return?gas_rate;
}
double?Stu::Stotal()????//計(jì)算總的錢
{
total=SGetG()+SGetW()+SGetC();
return?total;
}
//*************************************************************************************
class?arrayofStu??//學(xué)生類計(jì)算
{
public:
arrayofStu(int?sz=1)????{size=sz;??student=new?Stu[size];}??//構(gòu)造函數(shù)
????~arrayofStu()???{?delete?[]?student;??}??
???void??xuesheng();???????//學(xué)生用戶主菜單??
???void?jiaofei();?????????//學(xué)生交費(fèi)菜單
???void?regist();??????????//登記學(xué)生?
???????void?amend(?);??????//修改用戶菜單
???????void??add(?);??????//增加用戶
???void?delet();???????//?刪除用戶菜單
???????void?nad();????????//姓名刪除
???????void?numd();??????????//學(xué)號(hào)刪除??
???????void?check(?);??????//查詢菜單
???????void??nacheck();???????//姓名查詢
???????void?numcheck();?????//學(xué)號(hào)查詢
???????void?naj();?????????//輸入姓名交費(fèi)
???????void?numj();???????//輸入學(xué)號(hào)交費(fèi)
???????void?display();??//查看交費(fèi)情況
???????void?save();
???????
private:
????????
?????????int?size;
?????????Stu??*student;
??
};
?
void?arrayofStu::regist()????????//學(xué)生用戶注冊(cè)
{int?i=0;?
ifstream?f(“Stu.txt“);
while(f.good())??//?!f.eof()
{
f>>student[i].number;
f>>st
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????338??2009-06-19?01:31??C++代碼\Stu.txt
?????文件????????337??2009-06-18?13:33??C++代碼\Teacher.txt
?????文件??????21829??2009-06-19?01:40??C++代碼\電煤氣管理系統(tǒng).cpp
?????目錄??????????0??2009-06-20?20:46??C++代碼
-----------?---------??----------?-----??----
????????????????22504????????????????????4
評(píng)論
共有 條評(píng)論