Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

Urgent help!!!!!!!!!!!!!!!!!!:->in c++

Know the answer? Have a better solution? Share it.
Sign Up Now for FREE!
Join the thousands of students
getting ahead in their classes.
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Novice
Karma Points: 36
Respect (48%):
Date Posted: 7/24/2008 1:04:21 AM  Status: Live
Urgent help!!!!!!!!!!!!!!!!!!:->in c++
Course Textbook Chapter Problem
Data Structures C++: How to Program (5th) by Deitel, Deitel, Deitel N/A N/A
Question Details:
 

 

Instructions

Please read the following instructions (related project code) carefully:

You'll be expected to observe good programming standards.

  • Project code must follow C++ syntax
  • Data used in each project must be retrieve and saved in Text Files
  • Your project may cover the concepts learnt in CS201 particularly

1.      Structures

2.      Dynamic memory allocation

3.      Text Files

4.      Classes , Friend functions ,Function overloading

  • You must include a comment explaining the purpose of every variable you use in your program.
  • You must use meaningful, suggestive, self-explanatory variable names.
  • Precede every major block of your code with a comment explaining its purpose.
  • Indent the code properly for making it more understandable

 

It should be clear that your project will not get any credit if:

o                    The project is submitted after due date.

o                    The submitted project does not open or file corrupt.

o                    The project is copied.

Note: You have to submit Source code (.cpp) , executable file (.exe) and text files (.txt) of your project.

 

Objective

The objective of project is to enhance your knowledge and sharpen your analytical and programming abilities so that you can work in a professional environment.

 

Project Title: Daewoo (a Bus service) Reservation System

Project Description:

This program is supposed to simulate a Reservation System of Daewoo. Using this program, Daewoo ticket reservation agency assistant can perform different tasks related to ticket reservation.

 

The Daewoo Reservation System will ask the user for the following information :

  • Name of passenger
  • Departure City
  • Destination City
  • Date of travel
  • Time of travel
  • Number of tickets

The Daewoo Reservation System should have the following features:

 

  1. Make Reservation-to reserve ticket/tickets for a passenger and indicate his/her seat number.
  2. Modify reservation-to modify the already made reservation
  3. Cancel reservation-to cancel a particular reservation
  4. Search reservation- to search reservation information of a particular passenger by

a)      Passenger name

b)      Date of travel

  1. Exit –to exit from application

 

Daewoo Reservation System should also support persistence for passenger ticket reservation records

Supporting simple persistence by any application requires handling of two scenarios

  • On start up of application-data (passenger ticket reservation records) must be read from file. 
  • On end/finish up of application -data (passenger ticket reservation records) must be saved in file.

 

Answers:

Cramster Expert

Member's Avatar

(Cramster SME)
Moderator
Cramster In-House Subject Matter Expert
Date Posted: 7/25/2008 8:49:09 AM  Status: Live
Asker's Rating: None Provided    Moderator's Rating: N/A
Response:
 
Dear User
 
This question needs lot of information to work out this project.
 
The good and clear points are
      On start up of application-data (passenger ticket reservation records) must be read from file. 
      On end/finish up of application -data (passenger ticket reservation records) must be saved in file.
 
Missing Point
      Structure of the data / record of how the data should be stored in the file and specification of data types.
      Whether the contents should be written back to the same file or into a new file
 
The good and clear points are
      The four options that should be in the menu ( Reservation, Modification, Cancellation and Search)
      Also it was given on what it should be search and search keys details
 
Missing Point
      Procedures on how a reservation should be done and the constraints associated with them.
      No details about how to organize the Bus ( like number of buses, numbers of seats etc)
      Passenger and Bus topics were discussed. But, how to relate them was not described
 
Here is what a start of the program. Hope it will help you. If you can provide some details, we were certain of working out completely the question.
 

#include<iostream> // Allows program to perform input and output

using std::cout; // program uses cout

using std::cin; // program uses cin

using std::ios;

# include<string>

using std::string;

# include<fstream>

using std::ifstream;

using std::ofstream;

class Passenger

{

public :

void getPassenger()

{

cout << "\n\n\tEnter your name : ";

cin >> passengerName;

cout << "\tDeparture City : ";

cin >> departureCity;

cout << "\tDestination City : ";

cin >> destinationCity;

cout << "\tDate of Travel : ";

cin >> travelDate;

cout << "\tTime of Travel : ";

cin >> travelTime;

cout << "\tNumber of tickets: ";

cin >> numberOfTickets;

} // end function getPassenger

string passengerName;

string departureCity;

string destinationCity;

string travelDate;

string travelTime;

int numberOfTickets;

}; // end structure Passenger

class Bus

{

friend class Passenger;

public :

Bus()

{

seats = 0;

departureCity = "";

destinationCity = "";

travelDate = "";

travelTime = "";

} // end constructor

Bus( string depCity, string desCity, string tDate, string tTime )

{

seats = 0;

departureCity = depCity;

destinationCity = desCity;

travelDate = tDate;

travelTime = tTime;

} // end overloaded contructor

string getDepartureCity()

{

return departureCity;

} // end function getDepartureCity

string getDestinationCity()

{

return destinationCity;

} // end function getDestinationCity

bool reserve( Passenger p )

{

if ( ( p.departureCity.compare( this->departureCity ) == 0 ) &&

( p.destinationCity.compare( this->destinationCity ) == 0 ) &&

( p.travelDate.compare( this->travelDate ) == 0 ) &&

( p.travelTime.compare( this->travelTime ) == 0 ) )

{

if ( p.numberOfTickets <= ( 30 - seats ) )

{

cout << "\n\n\tYou ticket numbers are from " << seats;

seats += p.numberOfTickets;

cout << " to " << seats;

return true;

}

else

cout << "\n\n\t" << p.numberOfTickets

<< " were not available in the bus.";

}

else

cout << "\n\n\tThis was not the bus you were looking for.";

return false;

}

private:

int seats;

string departureCity;

string destinationCity;

string travelDate;

string travelTime;

}; // end class Bus

int main() // function main begins program execution

{

ifstream readFile;

Bus myBus[ 3 ];

Passenger pp;

// let the user know about the program

cout << "\n\n\t\t\tDaewoo Reservation System ";

// Open the input file for input.

readFile.open( "daewoo.txt", ios::in);

// Display error when the file was not opened

if( !readFile.is_open())

{

cout << "Unable to open the input file.\n\n\t";

system( "pause" );

return 1;

} // end if

 

char choice;

do {

cout << "\n\n\tMake Reservation : R";

cout << "\n\tModify reservation : M ";

cout << "\n\tCancel reservation : C";

cout << "\n\tSearch reservation : S ";

cout << "\n\n\tExit : E";

cin >> choice;

switch( choice )

{

case 'R' :

case 'r' : pp.getPassenger();

for ( int i = 0; i < 3; i++ )

{

if ( myBus[ i ].reserve( pp ) )

break;

}

break;

case 'M' :

case 'm' : //reserve();

break;

case 'C' :

case 'c' : //cancel();

break;

case 'S' :

case 's' : //search();

break;

case 'E' :

case 'e' : choice = 'e';

break;

} // end switch

} while ( choice != 'q' ); // end do-while

// let the screen pause for the user to see the output

cout << "\n\n\t";

system( "pause" );

return 0; // indicates program executed successfully

} // end of function, main

 
 



By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.