資源簡介
大一c++課程設計中的電煤氣管理系統
這是關于高校電煤氣管理系統的c++源代碼

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