C++高速公路收费系统代码

#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;
        }
    }
    void write()    //记录信息
    {
        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;
mp3手表            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;
        cout<<"_________________________________________________________________"<<endl;
        while((())!=EOF)
            cout<<ch;
        return 0;
    }
     
    int opensf3()              //打开记录信息文档3
    {
        char ch;
        ifstream of("记录数据2.txt");
        cout<<"车型"<<"  "<<"车号"<<"      "<<"费用"<<" "<<"收款人"<<" "<<"日期"<<endl;

本文发布于:2024-09-21 19:06:47,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/3/154864.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:输入   记录   打开   信息   代表   文档   数据
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议