#include<iostream>
#include<windows.h>
#include<conio.h>
#include<fstream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
using namespace std;
int k=7,r=0,flag=0;
COORD coord = {0, 0};
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
struct date
{
int mm,dd,yy;
};
ofstream fout;
ifstream fin;
class ticket
{
int itemno;
char name[25];
date d;
public:
void add()
{
cout<<"\n\n\tTicket No: ";
cin>>itemno;
cout<<"\n\n\tName of the Movie: ";
cin>>name;
cout<<"\n\n\tReleasing Date(dd-mm-yy): ";
cin>>d.mm>>d.dd>>d.yy;
}
void show()
{
cout<<"\n\tTicket No: ";
cout<<itemno;
cout<<"\n\n\tName of the Movie: ";
cout<<name;
cout<<"\n\n\tReleasing Date : ";
cout<<d.mm<<"-"<<d.dd<<"-"<<d.yy;
}
void report()
{
gotoxy(3,k);
cout<<itemno;
gotoxy(13,k);
//puts(name);
cout<<name;
}
int retno()
{
return(itemno);
}
};
class amount: public ticket
{
float price,qty,netamt;
public:
void add();
void show();
void report();
void calculate();
void pay();
float retnetamt()
{
return(netamt);
}
}amt;
void amount::calculate()
{
netamt=qty*price;
}
void amount::add()
{
ticket::add();
cout<<"\n\n\tPrice: ";
cin>>price;
cout<<"\n\n\tQuantity: ";
cin>>qty;
calculate();
fout.write((char *)&amt,sizeof(amt));
fout.close();
}
void amount::show()
{
fin.open("itemstore.dat",ios::binary);
fin.read((char*)&amt,sizeof(amt));
ticket::show();
cout<<"\n\n\tNet Amount: ";
cout<<netamt;
fin.close();
}
void amount::report()
{
ticket::report();
gotoxy(23,k);
cout<<price;
gotoxy(33,k);
cout<<qty;
gotoxy(64,k);
cout<<netamt;
k=k+1;
if(k==50)
{
gotoxy(25,50);
cout<<"PRESS ANY KEY TO CONTINUE...";
getch();
k=7;
system("cls");
gotoxy(30,3);
cout<<" TICKET DETAILS ";
gotoxy(3,5);
cout<<"NUMBER";
gotoxy(13,5);
cout<<"NAME";
gotoxy(23,5);
cout<<"PRICE";
gotoxy(33,5);
cout<<"QUANTITY";
gotoxy(36,5);
cout<<"NET AMOUNT";
}
}
void amount::pay()
{
show();
cout<<"\n\n\n\t\t*********************************************";
cout<<"\n\t\t DETAILS ";
cout<<"\n\t\t*********************************************";
cout<<"\n\n\t\tPRICE :"<<price;
cout<<"\n\t\tQUANTITY :"<<qty;
cout<<"\n\n\t\tNET AMOUNT\t :$"<<netamt;
cout<<"\n\n\t\t*********************************************";
}
int main()
{
gotoxy(40,4);
cout<<"==================================\n\n";
gotoxy(40,5);
cout<<"\tUSER PANEL - LOGIN ";
gotoxy(40,6);
cout<<"==================================\n\n";
string username=" ";
string password=" ";
bool loginSucess= false;
do
{
gotoxy(40,10);
cout<<"Enter Username: ";
cin>> username;
gotoxy(40,12);
cout<<"Enter Password: ";
cin>> password;
if(username=="admin" && password=="admin")
{
cout<<"\n You're 'sucessfully logged in\n\n" ;
loginSucess = true;
}else
{
cout<<" Incorrect username and password\n";
cout<<" Please try to login again";
}
} while(!loginSucess);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout<<setprecision(2);
fstream tmp("temp.dat",ios::binary|ios::out);
menu:
system("cls");
gotoxy(25,2);
cout<<"==============================\n\n";
gotoxy(25,3);
cout<<"MOVIE TICKET MANAGEMENT SYSTEM ";
gotoxy(25,4);
cout<<"==============================\n\n";
//gotoxy(25,5);
cout<<"\n\t\t1.CART REPORT \n\n";
//gotoxy(25,6);
cout<<"\n\t\t2.ADD/REMOVE/EDIT Ticket\n\n";
//gotoxy(25,7);
cout<<"\n\t\t3.SHOW TICKET DETAILS\n\n";
//gotoxy(25,8);
cout<<"\n\t\t4.EXIT\n\n";
//gotoxy(25,9);
cout<<"\n\t\tPlease Enter Required Option: ";
int ch,ff;
float gtotal;
cin>>ch;
switch(ch)
{
case 1:
ss:
system("cls"); //clear screen mode
gotoxy(25,2);
cout<<"CART DETAILS";
gotoxy(25,3);
cout<<"================\n\n";
cout<<"\n\t\t1.All Ticketa\n\n";
cout<<"\t\t2.BACK TO MAIN MENU\n\n";
cout<<"\t\tPlease Enter Required Option: ";
int cho;
cin>>cho;
if(cho==1)
{
system("cls");
gotoxy(30,3);
cout<<" CART DETAILS ";
gotoxy(3,5);
cout<<"NO";
gotoxy(13,5);
cout<<"NAME";
gotoxy(23,5);
cout<<"PRICE";
gotoxy(33,5);
cout<<"QUANTITY";
gotoxy(64,5);
cout<<"NET AMOUNT";
fin.open("itemstore.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
goto menu;
}
fin.seekg(0); //Set position in input sequence. Sets the position of the next character to be extracted from the input stream.
gtotal=0;
while(!fin.eof())
{
fin.read((char*)&amt,sizeof(amt));
if(!fin.eof())
{
amt.report();
gtotal+=amt.retnetamt();
ff=0;
}
if(ff!=0)
gtotal=0;
}
gotoxy(17,k);
cout<<"\n\n\n\t\t\tGrand Total="<<gtotal;
getch();
fin.close();
}
if(cho==2)
{
goto menu;
}
goto ss;
case 2:
db:
system("cls");
gotoxy(25,2);
cout<<"============\n\n";
gotoxy(25,3);
cout<<"MAIN SECTION";
gotoxy(25,4);
cout<<"============\n\n";
cout<<"\n\t\t1.ADD TICKET DETAILS\n\n";
cout<<"\t\t2.EDIT TICKET DETAILS\n\n";
cout<<"\t\t3.DELETE TICKET DETAILS\n\n";
cout<<"\t\t4.BACK TO MAIN MENU";
int apc;
cin>>apc;
switch(apc)
{
case 1:
fout.open("itemstore.dat",ios::binary|ios::app);
amt.add();
cout<<"\n\t\tTicket Added Successfully!";
getch();
goto db;
case 2:
int ino;
flag=0;
cout<<"\n\n\tENTER TICKET NUMBER TO BE EDITED :";
cin>>ino;
fin.open("itemstore.dat",ios::binary);
fout.open("itemstore.dat",ios::binary|ios::app);
if(!fin)
{
cout<<"\n\nFile Not Found...";
goto menu;
}
fin.seekg(0);
r=0;
while(!fin.eof())
{
fin.read((char*)&amt,sizeof(amt));
if(!fin.eof())
{
int x=amt.ticket::retno();
if(x==ino)
{
flag=1;
fout.seekp(r*sizeof(amt));
system("cls");
cout<<"\n\t\tCURRENT DETAILS ARE\n";
amt.show();
cout<<"\n\n\t\tENTER NEW DETAILS\n";
amt.add();
cout<<"\n\t\tTICKET DETAILS EDITED";
}
}r++;
}
if(flag==0)
{
cout<<"\n\t\tTicket No does not exist...Please Retry!";
getch();
goto db;
}
fin.close();
getch();
goto db;
case 3:
flag=0;
cout<<"\n\n\tEnter Ticket Number to be deleted :";
cin>>ino;
fin.open("itemstore.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
goto menu;
}
fin.seekg(0);
while(fin.read((char*)&amt, sizeof(amt)))
{
int x=amt.ticket::retno();
if(x!=ino)
tmp.write((char*)&amt,sizeof(amt));
else
{
flag=1;
}
}
fin.close();
tmp.close();
fout.seekp(0);
tmp.open("temp.dat",ios::binary|ios::in);
if(!tmp)
{
cout<<"Error in File";
goto db;
}
while(tmp.read((char*)&amt,sizeof(amt)))
fout.write((char*)&amt,sizeof(amt));
tmp.close();
fout.close();
if(flag==1)
cout<<"\n\t\tTicket Succesfully Deleted";
else if (flag==0)
cout<<"\n\t\tTicket does not Exist! Please Retry";
getch();
goto db;
case 4:
goto menu;
default: cout<<"\n\n\t\tYou Choose Wrong Choice!!! Retry";
getch();
goto db;
}
case 3:
system("cls");
flag=0;
int ino;
cout<<"\n\n\t\tENTER TICKET NUMBER:";
cin>>ino;
fin.open("itemstore.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...\nProgram Terminated!";
goto menu;
}
fin.seekg(0);
while(fin.read((char*)&amt,sizeof(amt)))
{
int x=amt.ticket::retno();
if(x==ino)
{
amt.pay();
flag=1;
break;
}
}
C++源代码的电影票管理系统.zip
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
![avatar](https://profile-avatar.csdnimg.cn/f6f011970f0f4dc0b48561c888fd7c9f_xipengbozai.jpg!1)
卷积神经网络
- 粉丝: 342
- 资源: 8460
最新资源
- 基于Python+Tensorflow实现声纹识别+源代码+文档说明.zip
- java-leetcode题解之第112题路径总和.zip
- java-leetcode题解之第111题二叉树的最小深度.zip
- java-leetcode题解之第110题平衡二叉树.zip
- java-leetcode题解之第109题有序链表转换二叉搜索树.zip
- java-leetcode题解之第108题将有序数组转换为二叉搜索树.zip
- java-leetcode题解之第107题二叉树的层序遍历II.zip
- java-leetcode题解之第102题二叉树的层序遍历.zip
- java-leetcode题解之第103题二叉树的锯齿形层序遍历.zip
- java-leetcode题解之第104题二叉树的最大深度.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)