hi every one

iam new member in your sites

and i hope i will find what iam looking for:rolleyes:

so my friends i really want ur help

iam students in univerisity 3rd level and our teacher ask us to write program in c++

this one below


{
Develop an Airline Reservation System in which five arrays are maintained. The first array has the names of the customers, the second array has the number of seats the customer wants, the third array has the destination city of customer, the fourth array has the amount he has paid, and the fifth array has information about whether the customer’s reservation is confirmed or not – so this fifth array can have values either ‘confirmed’ or ‘unconfirmed’. Your program should read arbitrary data from an input file "reservations.txt", and then displays a menu with the following options:

1. Add a new reservation
2. Show details of a reservation (given reservation number)
3. Make Payment (given the reservation number and payment amount)
4. Confirm a Reservation (given the reservation number)
5. Quit

The index of the array should be taken as the Reservation number. So for example if you want to check or update any information related to reservation number 3, then you can actually work with the values in the third index of all the arrays. If you add a new reservation, then obviously a new reservation number will be generated as you will add a new index in all the arrays.
When your program is quit you should make sure that before quitting all the changes in the arrays are written into the “reservation.txt – Basically all information in “reservation.txt should be updated according to all activities done in your program, e.g. adding a new reservation, making payment and confirming reservation.

You should apply modular programming, with a separate function for each major task in your program.
}

so iam really want ur help in that:sad:

and thank u very much

and this is my e-mail
(hot_sun_03@hotmail.com)

Recommended Answers

All 10 Replies

We are not here to do your homework. Let's start with how you have thought of approaching the problem first. We will be helping you on the way.

ok

i will start....

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
void main (void)
{
int x , a ,z,b,A,c;
int names[], number of seats[], 
destination city[], payment[], info[];
 
FILE *reservations;
first = fopen("reservations.txt","r");
 
printf("Welcome to Airline Reservation System. \n");
printf("******************************************************************\n");

so is it correct up to now?

and how can i proceed?

It seems to be going in the right direction.

You next step is to identify the functions which can be created, like addReservation(), showReservationDetails() and so on.

i really stuck,

i want you to explain to me in general what shall i do in the program

if u don`t mind

i really want to learn

and i will try to write the program by myself

Well, the directions indicate you need to set up 5 arrays, so that might be one step you could take. This shouldn't be too hard, if you've been paying attention in class and doing the homework to date.

Then you could set up a display menu and declare a variable to hold user input which can then be used as the conditional of a switch statement to trigger calling functions needed to implement a variety of activities listed in then menu.

how about this at the beginning?

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int x(char names[], char destination[], char info[], int number_seats[], int payment[]);
void main (void)
{
   int x , a , z, b, A, c;
   char names[50], destination[50], info[50];
   int number_seats[50], payment[10];

   printf("Welcome to Airline Reservation System. \n");
   printf("******************************************************************\n");
   printf("\nplease enter the custumer name\n: ");
   scanf("%c",&names);
   printf("\nHow many seats do you want ?\n");
   scanf("%d",&number_seats);
   printf("\nWhere do you want to go?\n");
   scanf("%c",&destination);
   {
      printf("You must pay << 50 SR.>> for the reservations :\n");
      scanf("%d",&payment[50]);
      while ( payment[10]!=50 )
      {
         printf("\nPlease Enter << 50 SR >> ONLY ! Thank you:");
         scanf("%d",&payment[50]);
      }
   }
}

hi evey body

finally i`ve finished my project

but if u have any comments about it please hlp me in that

i will be gld to see ur comments to improve my project

last day for submission is monday

#include<stdio.h>
#include<stdlib.h>
#define MAX 30
int menu(){
int choice;
printf("1. Add a new reservation\n");
printf("2. Show details of a reservation (given reservation number)\n");
printf("3. Make Payment (given the reservation number and payment amount)\n");
printf("4. Confirm a Reservation (given the reservation number)\n");
printf("5. Quit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
return(choice);
}
int GetReservationNumber(){
int PNR;
do{
printf("Enter reservation number: ");
scanf("%d", &PNR);
if(PNR < 0)
printf("Wrong number\n");
}while(PNR < 0);
return(PNR);
}
 
void DisplayInfo(char first[][15], char last[][15], int seats[], char destination[][15], float amount[], int confirmed[], int PNR){
printf("\nNAME : %s %s\n", first[PNR], last[PNR]);
printf("# SEATS : %d\n", seats[PNR]);
printf("DESTINATION: %s\n", destination[PNR]);
printf("AMOUNT : %.3f SAR\n", amount[PNR]);
if(confirmed[PNR] == 1)
printf("STATUS : CONFIRMED\n\n");
else
printf("STATUS : UNCONFIRMED\n\n");
}
void AddNew(char first[][15], char last[][15], int seats[], char destination[][15], int n){
printf("Enter first name: ");
scanf("%s", first[n]);
printf("Enter last name: ");
scanf("%s", last[n]);
do{
printf("Enter number of seats: ");
scanf("%d", &seats[n]);
if(seats[n] <= 0)
printf("Wrong number\n");
}while(seats[n] <= 0);
printf("Enter destination: ");
scanf("%s", destination[n]); 
}
void GetAmount(float amount[], int PNR){
do{
printf("Enter the amount in SAR: ");
scanf("%f", &amount[PNR]);
if(amount[PNR] <= 0)
printf("Wrong amount\n");
else
printf("Thank you\n\n");
}while(amount[PNR] <= 0);
}
main(){
int seats[MAX], confirmed[MAX], n, reserved[MAX], i, PNR, choice;
float amount[MAX];
char first[MAX][15], last[MAX][15], destination[MAX][15];
FILE *inp, *outp;
inp = fopen("E:reservat.txt", "r");
if(inp == NULL){
printf("Cannot open the file ");
exit(1);
}
for(i = 0; i < MAX; i++)
reserved[i] = 0;
n = 0;
for(int status = fscanf(inp, "%s", first[n]);
status != EOF;
status = fscanf(inp, "%s", first[n])){
fscanf(inp, "%s%d%s%f%d", last[n], &seats[n], destination[n], &amount[n], &confirmed[n]);
reserved[n] = 1;
n++;
}
fclose(inp);
do{
choice = menu();
switch(choice){
case 1: if(n < MAX){
AddNew(first, last, seats, destination, n);
reserved[n] = 1;
printf("Thank You, your reservation number is %d (Unconfirmed)\n\n", n);
n++;
}else
printf("The arrays are full\n\n");
break;
case 2: PNR = GetReservationNumber();
if(reserved[PNR] == 1)
DisplayInfo(first, last, seats, destination, amount, confirmed, PNR);
else
printf("Not Found\n\n");
break;
case 3: PNR = GetReservationNumber();
if(reserved[PNR] == 1)
GetAmount(amount, PNR);
else
printf("Not Found\n\n");
break;
case 4: PNR = GetReservationNumber();
if(reserved[PNR] == 1){
confirmed[PNR] = 1;
printf("The reservation is confirmed\n\n");
}else
printf("Not Found\n\n");
break;
case 5: outp = fopen("a:reservation.txt", "w");
for(i = 0; i < n; i++)
fprintf(outp, "%s %s %d %s %.3f %d\n", first[i], last[i], seats[i], destination[i], amount[i], confirmed[i]);
fclose(outp);
printf("Thank You..");
break;
default: printf("Wrong Choice\n\n");
}
}while(choice != 5);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.