#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
class Car //定义一个类
{
private:
char cheXing[20],cheHao[20],people[30],time[30]; //定义成员变量
int ruKou,gongLi;
double feiYong;
public:
void sum() //计算费用
{
int a,b,c;
switch (ruKou)
{
system("cls"); //
case 1:
动物冬眠的方式 if(a) feiYong=gongLi*0.5;
else if(b) feiYong=gongLi*0.4;
else if(c) feiYong=gongLi*0.3;
cout<<"所收费用为:"<<feiYong<<"元"<<endl;
break;
case 2:
if(a) feiYong=gongLi*0.5;
else if(b) feiYong=gongLi*0.4;
else if(c) feiYong=gongLi*0.3;
cout<<"所收费用为:"<<feiYong<<"元"<<endl;
break;
case 3:
if(a) feiYong=gongLi*0.5;
else if(b) feiYong=gongLi*0.4;
else if(c) feiYong=gongLi*0.3;
cout<<"所收费用为:"<<feiYong<<"元"<<endl;
break;
}
}
{
int a,b,c;
cout<<"请输入路口(1、2、3):"<<endl;
cin>>ruKou;
cout<<"请输入车型(输入a,b,c. 'a-代表大型车,b-代表中型车,c-代表小型车'):"<<endl;
cin>>cheXing;
cout<<"请输入车牌号:"<<endl;
胡慧中照片 cin>>cheHao;
cout<<"请输入路程(单位为公里):"<<endl;
cin>>gongLi;
cout<<"请输入收费人:"<<endl;
cin>>people;
cout<<"请输入日期(格式:****-**-** . 年-月-日):"<<endl;
cin>>time;
}
void show() //打印记录情况
{
cout<<"车型"<<" "<<"车号"<<" "<<"费用"<<" "<<"收款人"<<" "<<"日期"<<endl;
cout<<"________________________________________________________________"<<endl;
cout<<cheXing<<" "<<cheHao<<" "<<feiYong<<" "<<people<<" "<<time<<endl;
}
int save() //记录信息写入3个文档
{
if(ruKou==1)
{
ofstream sf("记录数据1.txt",ios::app);
if(!sf)
{
cout<<"文件打开失败"<<endl;
return -1;
}
sf<<cheXing<<" "<<cheHao<<" "<<feiYong<<" "<<people<<" "<<time<<endl;
sf.close();
cout<<"\n数据已保存成功!\n"<<endl;
return 0;
}
if(ruKou==2)
{
ofstream sf("记录数据2.txt",ios::app);
if(!sf)
{
cout<<"文件打开失败"<<endl;
return -1;
}
sf<<cheXing<<" "<<cheHao<<" "<<feiYong<<" "<<people<<" "<<time<<endl;
sf.close();
cout<<"\n数据已保存成功!\n"<<endl;
return 0;
}
if(ruKou==3)
{
ofstream sf("记录数据3.txt",ios::app);
if(!sf)
{
cout<<"文件打开失败"<<endl;
return -1;
}
sf<<cheXing<<" "<<cheHao<<" "<<feiYong<<" "<<people<<" "<<time<<endl;
sf.close();
cout<<"\n数据已保存成功!\n"<<endl;
return 0;
}
}
int tongJi() //写入统计信息
{
ofstream tj("统计数据.txt",ios::app);
if(!tj)
{
cout<<"文件打开失败"<<endl;
孟子语录 return -1;
}
tj<<ruKou<<" "<<cheXing<<" "<<people<<endl;
tj.close();
return 0;
}
int openTj() //打开统计信息文档
{
char d;
ifstream ot("统计数据.txt");
cout<<"路口"<<" "<<"车型"<<" "<<"收款人"<<endl;
cout<<"________________________________"<<endl;
while((())!=EOF)
cout<<d;
return 0;
}
int opensf1() //打开记录信息文档1
{
char ch;
ifstream of("记录数据1.txt");
cout<<"车型"<<" "<<"车号"<<" "<<"费用"<<" "<<"收款人"<<" "<<"日期"<<endl;
cout<<"_________________________________________________________________"<<endl;
cout<<cheXing<<" "<<cheHao<<" "<<feiYong<<" "<<people<<" "<<time<<endl;
while((())!=EOF)
cout<<ch;
return 0;
有关月亮的神话传说 }
int opensf2() //打开记录信息文档2
{
char ch;
ifstream of("记录数据2.txt");
cout<<"车型"<<" "<<"车号"<<" "<<"费用"<<" "<<"收款人"<<" "<<"日期"<<endl;
iphone5拆机 cout<<"_________________________________________________________________"<<endl;
while((())!=EOF)
cout<<ch;
return 0;
}
int opensf3() //打开记录信息文档3
{
char ch;
ifstream of("记录数据2.txt");
解锁教程 cout<<"车型"<<" "<<"车号"<<" "<<"费用"<<" "<<"收款人"<<" "<<"日期"<<endl;
发布评论