Click here to Skip to main content
16,004,927 members
Home / Discussions / C#
   

C#

 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart20-Dec-04 5:57
protectorHeath Stewart20-Dec-04 5:57 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz21-Dec-04 1:05
stefan houtz21-Dec-04 1:05 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart21-Dec-04 7:55
protectorHeath Stewart21-Dec-04 7:55 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz22-Dec-04 2:52
stefan houtz22-Dec-04 2:52 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart22-Dec-04 6:38
protectorHeath Stewart22-Dec-04 6:38 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz27-Dec-04 6:01
stefan houtz27-Dec-04 6:01 
GeneralDataTable.ColumnChanged doesn't rais an event after ReadXml() Pin
Dogan Gunay20-Dec-04 0:05
Dogan Gunay20-Dec-04 0:05 
Generalhelp request..., Pin
50519-Dec-04 23:56
50519-Dec-04 23:56 
i've a problem with the code below on how i've used the structure,binary files and some of the functions!
the code:

/* bus reservation system*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAXSEAT 45
#define FILE1 fptr1;
#define FILE2 fptr2;

struct info {
char name[15];
char date[8];
char dest[15];
int seat;
float amount;
char mark;

};struct info record;

void ticket();
void sold_seat();
void reservation();
void thank_u();
void bus_fare();
void bus_report();
void check_it();
int q,rseat;

main()
{
int op;
START:printf("1:MAKE RESERVATION\n");
printf("2:SELL A TICKET\n");
printf("3:EXIT\n");
printf("enter your choice:\n");
scanf("%d",&op);
switch(op)
{case 1:{reservation();}
break;
case 2:{ticket();}
break;
case 3:exit(0);
break;
default:{printf("\nenter listed choice!\n");
goto START;
break; }}
return 0;
}

void reservation()
{
FILE*fptr1,*fptr2;
char name[15],date[15],dest[15],bname[15];
int i,seat;
fptr1=fopen("bus.txt","rb");
fptr2=fopen("user.txt","wb");

while(!feof(fptr1))
printf("\nenter bus name:\n");
scanf("%s",bname);
fptr1=fopen("bus.txt","rb");
if (fptr1==NULL)

printf("\nenter name:\n");
scanf("%s",(record).name);
printf("\nenter your destination:\n");
scanf("%s",(record).dest);
printf("\ndate:\n");
scanf("%s",(record).date);
check_it();
fptr2=fopen("user.txt","rb+");
fscanf(fptr1,"%s%d",(record).name,&seat);

fclose(fptr1);
fclose(fptr2); thank_u();
}

void check_it()
{
FILE*fptr2;
int seat,rseat,pseat,n;
fptr2=fopen("user.txt","rb");

n=0;
while(!feof(fptr2))
{START: printf("enter seat no:\n");
scanf("%d",&seat);
if(seat==seat)
{printf("seat taken\n""pick another seat\n");
goto START; }
else
{scanf("%d",&seat);}
rseat=n+1;
pseat=MAXSEAT-rseat;
if(n=MAXSEAT)
{printf("bus full");
reservation();}
n++;}
fclose(fptr2);
}

void ticket()
{
FILE*fptr1;
char mark,name[15],bname[15];
int seat;
fptr1=fopen("bus.txt","rb");
printf("enter bus name:\n");
scanf("%s",bname);
while(!feof(fptr1))
if (fptr1=fopen("bus.txt","rb+")==NULL)
{reservation();
fclose(fptr1);}
else
{printf("enter name:\n");
scanf("%s",name);
printf("enter seat no:");
scanf("%d",&seat);
if(strcmp((record).name,name)&&(record.seat,seat)==0)
{{printf("seat paid??(Y/N)\n");
scanf("%c",mark);}
if(mark='Y' || 'y')
{bus_fare();} }
else
{printf("\nthe seat is reserved!\n");}
}fclose(fptr1); thank_u();
}

void thank_u()
{
printf("\n***THANK YOU***\n");
}

void bus_fare()
{
float amount,sum;
sold_seat();
printf("\nenter amount paid:\n");
scanf("%f",&amount);
sum=q*amount;
printf("\ntotal revenue:%f\n",sum);
}

void bus_report()
{
check_it();
sold_seat();
bus_fare();
}

void sold_seat()
{
int q,i;
char mark;
q=0;
for(i=1;i<=45;i++)
if(mark=='Y'||'y')
{q=q+1;
printf("\nseats reserved and tickets sold:%d\n",q);}
check_it();
printf("\nseats reserved and tickets not sold:%d\n",rseat-q);
printf("\nseats not reserved:\n",MAXSEAT-rseat);
}

project was:
In this project you will develop a program that can be used by a bus company to
manage reservations of potential travellers to the buses operated by the company.
When invoked the program should present the user with two choices and let user
choose by inputting corresponding number:
1.Make a reservation
2.Sell a ticket.
If user choose (1) the program should,
1.Prompt user to input Bus name and find the file with that name, if not found create
a binary file with given name for keeping reservations for that bus.
2.Create a structure with all information needed to record a reservation.
3.Check for consistency that the seat is not taken already and the bus is not full.
4.Write the reservation into the binary file for chosen bus maintaining consistency.
5.Thank the user and exit.
If user choose (2) the program should,
1.Ask the user to input the name of bus in which reservation was previously made.
2.If the bus file does not exist, inform the user of the problem and repeat step 1.
3.Ask user input name and seat number reserved
4.If name and seat number are correct, mark the seat as sold and record amount of
money paid for the seat.
5.Finally the program should thank the user for using the program and display a
pretty report showing the current status of chosen bus in terms of which seats are
reserved, which ones for which the ticket is sold and total revenue collected so far.
thanks.
GeneralRe: help request..., Pin
Colin Angus Mackay20-Dec-04 1:46
Colin Angus Mackay20-Dec-04 1:46 
Generalpropagating datagrid changes in the source database tables Pin
Rashid_Mehmood19-Dec-04 23:24
Rashid_Mehmood19-Dec-04 23:24 
GeneralRe: propagating datagrid changes in the source database tables Pin
Skynyrd20-Dec-04 0:13
Skynyrd20-Dec-04 0:13 
GeneralRe: propagating datagrid changes in the source database tables Pin
siddlingaSwami20-Dec-04 2:03
susssiddlingaSwami20-Dec-04 2:03 
GeneralReal Time Display Sound WaveForm While Acquiring Pin
Siew Eng19-Dec-04 19:22
Siew Eng19-Dec-04 19:22 
GeneralLate Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 14:53
Chris Richner19-Dec-04 14:53 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Daniel Turini19-Dec-04 17:13
Daniel Turini19-Dec-04 17:13 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 21:51
Chris Richner19-Dec-04 21:51 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 22:25
Chris Richner19-Dec-04 22:25 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:19
esakal19-Dec-04 14:19 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:09
esakal19-Dec-04 14:09 
Generaldynamically create multiple controls Pin
fredza19-Dec-04 8:04
fredza19-Dec-04 8:04 
GeneralRe: dynamically create multiple controls Pin
Heath Stewart20-Dec-04 6:28
protectorHeath Stewart20-Dec-04 6:28 
Generalproblem with extender provider Pin
esakal19-Dec-04 4:01
esakal19-Dec-04 4:01 
GeneralRe: problem with extender provider Pin
Colin Angus Mackay19-Dec-04 10:03
Colin Angus Mackay19-Dec-04 10:03 
QuestionHow can i know which form are activated? Pin
anta19-Dec-04 2:29
anta19-Dec-04 2:29 
AnswerRe: How can i know which form are activated? Pin
Heath Stewart20-Dec-04 6:12
protectorHeath Stewart20-Dec-04 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.