We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Assignment No. 03
Semester: Fall 2011

CS201: Introduction to Programming

Total Marks: 20

Due Date:29/12/2011

 

Instructions:

 

Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file is corrupt.
  • Assignment is copied(partial or full) from any source (websites, forums, students, etc)

 

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.

 

 

Objectives:

 

The objective of this assignment is to provide hands on experience of:

 

  • Structures
  • Dynamic Memory allocation in C/C++
  • String Manipulation Functions
  • File Handling

 

 

Guidelines:

 

  • Code should be properly indented and well commented.
  • Follow C/C++ rules while writing variable names, function names etc
  • Use only dev-C++ for this assignment.
  • Use appropriate C/C++ structure i.e. if-else; switch statement etc to get inputs from user where required (Marks will be deducted if inappropriate structure will be used).

 

 

 

 

 

 

 

 

Problem Statement:  Flight Reservation System

 

Write a program for Flight Reservation System which reserves the tickets for passengers of an Air Line according to their requirements. 

 

Detailed Description:

 

In the program, you are required to make a structure with name 'Reservation' and following are the data members of structure.

 

ñ  Passenger Name

ñ  Passenger Address

ñ  Date of flight

ñ  Destination to travel

ñ  Flight No

ñ  Seat No

 

In the main() function, create of variable of type Reservation. The variable of type Reservation should be created dynamically using memory allocation function. After that, create following user defined function as discussed below:

 

GetData(), this function will set the values of above created structure variable according to the inputs taken from user. It will prompt user to enter required information for the, Passenger Name, Passenger Address, Destination, Date of flight. User will be provided three options for the destination that is: Karachi, Lahore and Peshawar.

 

Assigning Flight No and Seat No:

 

The user will chose one of three destinations and program will assign an appropriate Flight No for the passenger. The Flight No will be assigned as below:

 

         Destination                    Flight No.

          Karachi                          201

          Peshawar                         233

          Lahore                           241

 

After Assigning Flight No, the Seat No. will be assigned randomly which can be any number from 0 to 200.

 

After assigning the values for the above created variable of Reservation structure, the structure will be passed to another user defined function WriteData() for writing it to the file.

 

 

In the function WriteData(), you are required to create a new text file name “data.txt” in same folder/directory where you have saved your .cpp file. Open this file by using file handling functions and then write all Reservation information in that file.

 

At the end, read all the data from file by creating a function named ReadData() and display the file contents on the screen.

 

 

Points To Remember:

 

Following points should be kept in mind and handled accordingly, otherwise marks will be deducted. 

 

ñ  Reading and writing from text file, must be done with standard file handling functions provided in handouts. 

ñ  All data members must be declared and initialized with appropriate data type.

ñ  Exceptional cases must be kept in mind and handled accordingly while taking input from user.

ñ   User must be prompted if there is any error while:

 

◦   Creating a file.

◦   Opening a file for reading/ writing.

 

 

 

 

 

 

 

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 2174

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

plz someone do this asignment......................

[font="Times New Roman"][size="3"][i]Quote:[/i][/size][/font][font="Times New Roman"][size="5"]#include <iostream.h> 
#include <string.h>
#include <stdlib.h>
#include <fstream.h>
using namespace std;
int random(int i)
{
return rand()%i;
}
struct Reservation
{
string Passenger_Name;
string Passenger_Address;
string Date_of_Flight;
string Destination_to_travel;
int Flight_No;
int Seat_No;
};
void GetData(Reservation[],int);
void WriteData(Reservation[], int);
void ReadData(Reservation[], int);
main
()
{
Reservation *res;
int i;
cout
"How many reservation you want: ";
cin
>>i;
res
= new Reservation[i];
GetData(res, i);
system
("pause");
}
void GetData(Reservation st[], int nn)
{
string n;
char ch;
int l;
for(int j=1;j<=nn;j++)
{
cout
"Enter Passenger Name for Passenger "j" : ";
cin
>>n;
st
[j-1].Passenger_Name=n;
cout
"Enter Passenger Address for Passenger "j" : ";
cin
>>n;
st
[j-1].Passenger_Address=n;
cout
"Enter Date of Flight for Passenger "j" : ";
cin
>>n;
st
[j-1].Date_of_Flight=n;
cout
"Enter Destination_to_travel for Passenger "j" : ";
cout
"Please Select from given"endl;
cout
"k for karachi"endl;
cout
"p for peshawar"endl;
cout
"L for lahore"endl;
cin
>>ch;
if( ch == 'p')
{
st
[j-1].Destination_to_travel="Peshawar";
st
[j-1].Flight_No=233;
st
[j-1].Seat_No=random(200);
}
if( ch == 'k')
{
st
[j-1].Destination_to_travel="Karachi";
st
[j-1].Flight_No=201;
st
[j-1].Seat_No=random(200);
}
if( ch == 'l')
{
st
[j-1].Destination_to_travel="Lahore";
st
[j-1].Flight_No=241;
st
[j-1].Seat_No=random(200);
}
else if( !(ch == 'p' || ch == 'k' || ch == 'l'))
{
cout
"Please select from list:"endl;
}
}
WriteData(st, nn);
}
void WriteData(Reservation abc[], int nn)
{
ofstream myfile
("abc.txt");
if (myfile.is_open())
{
for(int j=1;j<=nn;j++)
{
myfile
abc[j-1].Passenger_Nameendl;
myfile
abc[j-1].Passenger_Addressendl;
myfile
abc[j-1].Date_of_Flightendl;
myfile
abc[j-1].Destination_to_travelendl;
myfile
abc[j-1].Flight_Noendl;
myfile
abc[j-1].Seat_Noendl;
}
myfile
.close();
}
else cout "Unable to open file";
ReadData(abc, nn);
}
void ReadData(Reservation[], int)
{
string line;
ifstream myfile
("abc.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline
(myfile,line);
cout
line endl;
}
myfile
.close();
}
else cout "Unable to open file";
}[/size][/font]


[font="Times New Roman"][size="5"]

Is it complete assignment?

cs201 Introduction to Programming Assignment 3 Solution fall December 2011



Quote:#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <fstream.h>
using namespace std;
int random(int i)
{
return rand()%i;
}
struct Reservation
{
string Passenger_Name; 
string Passenger_Address;
string Date_of_Flight;
string Destination_to_travel; 
int Flight_No; 
int Seat_No;
};
void GetData(Reservation[],int);
void WriteData(Reservation[], int);
void ReadData(Reservation[], int); 
main()
{
Reservation *res;
int i;
cout"How many reservation you want: ";
cin>>i;
res = new Reservation[i];
GetData(res, i);
system("pause");
}
void GetData(Reservation st[], int nn)
{
string n;
char ch;
int l;
for(int j=1;j<=nn;j++)
{
cout"Enter Passenger Name for Passenger "j" : ";
cin>>n;
st[j-1].Passenger_Name=n;
cout"Enter Passenger Address for Passenger "j" : ";
cin>>n; 
st[j-1].Passenger_Address=n; 
cout"Enter Date of Flight for Passenger "j" : ";
cin>>n; 
st[j-1].Date_of_Flight=n; 
cout"Enter Destination_to_travel for Passenger "j" : ";
cout"Please Select from given"endl;
cout"k for karachi"endl;
cout"p for peshawar"endl;
cout"L for lahore"endl;
cin>>ch; 
if( ch == 'p')
{
st[j-1].Destination_to_travel="Peshawar";
st[j-1].Flight_No=233; 
st[j-1].Seat_No=random(200); 
}
if( ch == 'k')
{
st[j-1].Destination_to_travel="Karachi"; 
st[j-1].Flight_No=201; 
st[j-1].Seat_No=random(200); 
}
if( ch == 'l')
{
st[j-1].Destination_to_travel="Lahore"; 
st[j-1].Flight_No=241; 
st[j-1].Seat_No=random(200); 
}
else if( !(ch == 'p' || ch == 'k' || ch == 'l'))
{
cout"Please select from list:"endl;

}
WriteData(st, nn);

void WriteData(Reservation abc[], int nn)
{
ofstream myfile ("abc.txt");
if (myfile.is_open())
{
for(int j=1;j<=nn;j++)

myfile abc[j-1].Passenger_Nameendl;
myfile abc[j-1].Passenger_Addressendl;
myfile abc[j-1].Date_of_Flightendl;
myfile abc[j-1].Destination_to_travelendl;
myfile abc[j-1].Flight_Noendl;
myfile abc[j-1].Seat_Noendl;
}
myfile.close();
}
else cout "Unable to open file";
ReadData(abc, nn);
}
void ReadData(Reservation[], int) 
{
string line;
ifstream myfile ("abc.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout line endl;
}
myfile.close();
}
else cout "Unable to open file"; 
}

not complete assignments

Dear Sir Please Reply In Word file for this get word





dats nt runing...lots of error:(

RSS

Latest Activity

+ "αяsαℓ " Ќąƶµяɨ •" liked + M.Tariq Malik's discussion How the world is connected through submarine cable
8 minutes ago
Profile IconMuhammad Younas Rajpoot, Zeeshan Khalid, iramnadeem and 14 more joined Virtual University of Pakistan
1 hour ago
Profile IconSyeda Kinza and Rana Usman joined + M.Tariq Malik's group
1 hour ago
٤ دن replied to + "αяsαℓ " Ќąƶµяɨ •"'s discussion Happy Marriage to "Zee" & " Nomi weds Noor"....!
1 hour ago
٤ دن updated their profile
1 hour ago
༺łℳℜ₳₦༻ immy posted a discussion
2 hours ago
+ Danial replied to + "αяsαℓ " Ќąƶµяɨ •"'s discussion Happy Marriage to "Zee" & " Nomi weds Noor"....!
5 hours ago
Aijaz khan posted a discussion
5 hours ago
khurram us salam replied to + M.Tariq Malik's discussion ACC501 GDB Fall 2019 Solution & Discussion in the group ACC501 Business Finance
6 hours ago
khurram us salam joined + M.Tariq Malik's group
6 hours ago
+ ՏhehαrZααD + replied to + ՏhehαrZααD +'s discussion Assalamu Alaikum
7 hours ago
+ ! ! ! ! ! Blu Moon replied to + "αяsαℓ " Ќąƶµяɨ •"'s discussion Happy Marriage to "Zee" & " Nomi weds Noor"....!
8 hours ago
+ ! ! ! ! ! ! ! ! ! AG liked + Iuuoɔǝut +'s discussion After and Before Marriage situations
8 hours ago
+ ! ! ! ! ! ! ! ! ! AG liked + Iuuoɔǝut +'s discussion Rules for Happy Marriage Life
8 hours ago
+ ! ! ! ! ! ! ! ! ! AG liked +***piya o ry piya***+'s discussion eng201
8 hours ago
+ ! ! ! ! ! ! ! ! ! AG liked 彡JK彡 ❤️'s discussion جسکی سنو وہی فرشتہ
8 hours ago
+ ! ! ! ! ! ! ! ! ! AG liked + ! ❤INNOCENT❤'s discussion Faqeer
8 hours ago
+++"MinShah"+++ updated their profile
8 hours ago
abdul bari updated their profile
8 hours ago
Zain Arshad replied to + M.Tariq Malik's discussion ENG201 Business and Technical English Writing Assignment No 01 Fall 2019 Solution & Discussion in the group ENG201 Business and Technical English Writing
8 hours ago

Today Top Members 

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service