Thursday, 29 December 2011

Re: (VU-Study-Corner) help

kia ap cs101 ki help kar sakty han

On 12/29/11, ibrar ulhaq <ibrarulhaq@gmail.com> wrote:
> CS201 Assignment 3 Solution
> -------------------------
> #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_Name<<endl;
> myfile <<abc[j-1].Passenger_Address<<endl;
> myfile <<abc[j-1].Date_of_Flight<<endl;
> myfile <<abc[j-1].Destination_to_travel<<endl;
> myfile <<abc[j-1].Flight_No<<endl;
> myfile <<abc[j-1].Seat_No<<endl;
> }
> 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";
> }
>
> https://www.facebook.com/groups/298960126803279/
>
> --
> Join us at facebook: https://www.facebook.com/VU.Study.Corner
>
> Group Link: http://groups.google.com/group/VU-Study-Corner?hl=en
>
> Group Rules: http://groups.google.com/group/VU-Study-Corner/web/group-rules
>
> Unsubscribe: VU-Study-Corner+unsubscribe@googlegroups.com
>
> Adult contents, Spamming, Immoral & Rudish talk, Cell number, Websites &
> Groups links specially in paper days are strictly prohibited and banned in
> group.
>

--
Join us at facebook: https://www.facebook.com/VU.Study.Corner

Group Link: http://groups.google.com/group/VU-Study-Corner?hl=en

Group Rules: http://groups.google.com/group/VU-Study-Corner/web/group-rules

Unsubscribe: VU-Study-Corner+unsubscribe@googlegroups.com

Adult contents, Spamming, Immoral & Rudish talk, Cell number, Websites & Groups links specially in paper days are strictly prohibited and banned in group.

No comments:

Post a Comment