VC++
由于数据库暂时没学会,利用了文本文件进行保存修改用户数据
#include "iostream"
#include"string"
#include"fstream"
#include"iomanip"
using namespace std;
int count1=0,count11=0; //学生总数和交钱的人数
int count2=0,count22=0;
class Stu
{
public:
Stu(double xwater=0,double xpower=0,double xgas=0,string xnum="a",string xna="a"); //学生类构造函数
void operator =(Stu S); //赋值运算符重载
friend ostream &operator <<(ostream & a,Stu &S) //插入运算符重载
{ a<<setw(8)<<left<<;
a<<setw(8)<<left<<;//输出时左对齐8位
a<<setw(8)<<left<<;
a<<setw(8)<<left<<;
a<<setw(8)<<left<<;
a<<setw(8)<<left<<();
a<<setw(8)<<left<<();
a<<setw(8)<<left<<();
a<<setw(8)<<left<<();
if(!=0)
a<<"已交";
else a<<"未交";
cout<<endl;
return a;
}
double SGetW(); //计算水费
double SGetC(); //计算电费
double SGetG(); //计算煤气费
double Stotal(); //计算总费用
double water,power,gas,water_rate,circuit,gas_rate,total;
int flag;
string number,name;
};
Stu::Stu(double xwater,double xpower,double xgas,string xnum,string xna) //学生类构造函数
{
water=xwater;power=xpower;gas=xgas;
number=xnum;name=xna;
flag=0;
}
void Stu::operator =(Stu S) //赋值运算符重载
{
name=;
number=;
water=;
power=;
gas=;
}
double Stu::SGetW( ) //计算水费
{
if(water<10)
water_rate=0;
else
water_rate=*(water-10);
return water_rate;
}
double Stu::SGetC() //计算电费
{
if(power<10)
circuit=0;
else
circuit=*(power-10);
return circuit;
}
double Stu::SGetG() //计算煤气费
{
if(gas<10)
gas_rate=0;
else
gas_rate=*(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(); //学生交费菜单
宿舍系统代码实现 来自淘豆网m.daumloan.com转载请标明出处.