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.

 

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:

 

  • Classes
  • Function Overloading
  • Dynamic Memory allocation in C/C++
  • String Manipulation Functions
  • File Handling
  • Stream Manipulators

 

 

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:  Airline Fare System

Write a program for air fare System which will calculate fare on already reserved ticket.    

                                            

Detailed Description:

 

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

 

ñ  Seat type

ñ  Price

ñ  Tax

ñ  Airline charges

 

In the main () function, create a constructor of class to initialize the class data members. Class must have a destructor. Create following user defined function as discussed below along with class constructors and destructor:

 

GetData(), this function will take the input for seat type variable from the user and will set the ticket price according to the input taken from user. The function GetData() will prompt user to enter required information for seat type.

 

Seat Type:

User can select one of the Seat type:

 

1. First Class Seat

2. Business Class Seat

3. Economy Class Seat

 

The function GetData() will also read the data from file named data.txt ( created in assignment no 3 ) to read the destination and then assigns the price for the given destination.

 

 

Price:

Price will be calculated on the basis of following information:

 

1- Fare type

2- Destination (Desire destination information will be read from the file “data.txt” )

 

The price will be assigned according to the table given below:

 

 

 

 

Seat Type

Destination

Ticket Price

Economy Class

Karachi

3000

Economy Class

Peshawar                        

2500

Economy Class

Lahore

4000

Business Class

Karachi

5000

Business Class

Peshawar                         

4500

Business Class

Lahore

6000

First Class

Karachi

7000

First Class

Peshawar                        

7000

First Class

Lahore

7000

 

 

Airline charges:

All airlines will charge 15% of ticket price extra to the all fare types along with the tax.  

 

Class should have a user-defined function named CalculateTax() to calculate the tax according to seat type and ticket price.

 

Tax calculation will be done as below:

 

If seat type is First class then tax will be 30% of ticket price

If seat type is Business class then tax will be 20% of ticket price

If seat type if Economy class then tax will be 10%  of ticket price

 

 

Calculateprice(), this member function will calculate price of already reserved ticket and will display total fare on the screen. Price calculation will add above calculated tax, airline charges to the actual ticket price according to following information.

 

Fare = Airline Charges + Tax + Ticket Price

 

 

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

 

------------------------------------------------------------------------

Name | Address| Date | Destination | Flight. No | Seat. No | Fare

------------------------------------------------------------------------.

.

.

.

.

.

.

------------------------------------------------------------------------

 

Required information of Name, Address, Date, Destination, Flight No, Seat No, should be taken from assignment no 3 output file.  

 

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: 5005

.

+ 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

wo bila waja zero nai daitay .. wo daikhtay hain student ne khud koshish ki hai ya nai ... meri aik assignmnet mein mera pora prog theek nai tha, just end se coding ma masla tha bt prog theek chalta tha but wo pora ma ne khud kia tha n meri apni koshish thi ... n uno ne mje poray number diye thay

ck it and best of luck

Attachments:

g han dev mai main ki return type int krni parti he phr compile hota he

ha ha ha haha ............................friend solution nazil ho gia hay enjoy

Attachments:

#include <iostream>
#include <stdio.h>
#include <string> // String Manipulation
#include <fstream> // read/ write file
#include <windows.h> //for Pause function

using namespace std;

class airFare{
private: //it is private function
    string seatType;
    int Fare, Price, Tax, ALine;
public: //it is pubic function
    airFare();
    void GetData();
protected: //Protected, so only we can call, no one else can.
    int CalculatePrice(int Price, int Tax);
    int CalculateTax(int choice, int Price);
    void WriteData(string Name, string Address, string Date, string Destination, int Flight, int Seat, int Fare);
};
airFare::airFare(){
    Fare=0;
    Price=0;
    Tax=0;
    ALine=0; // Just initialized the variables.
};
void airFare::GetData()
{
    string Name, Address, Date, Destination; // declaring local variables
    int Flight, Seat, choice; // declaring local variables
mainMenu:
    cout "\nPlease select desired seat from the following options.\n\n";
    cout "1. First Class Seat\n2. Business Class Seat\n3. Economy Class Seat";
    cout "\n\nYour Choice: ";
    cin  >> choice;
    if(choice==1){
        seatType="First Class";
    }
    else if(choice==2){
        seatType="Business Class";
    }
    else if(choice==3){
        seatType="Economy Class";
    }
    else{
        cout "Error! Its not a valid choice"; // raise exception, can use catch & throw if was asked in assignment
        goto mainMenu;
    }
    ifstream booking("data.txt");
    if(!booking){
        cout "can't read from file data.txt"; // raise exception, can use catch & throw if was asked in assignment
    }
    else{
        while(booking>>Name>>Address>>Date>>Destination>>Flight>>Seat){
            switch(choice){
    case 1:
        if(Destination=="lahore"){
            Price=7000;
        }
        else if(Destination=="karachi"){
            Price=7000;
        }
        else{
            Price=7000;
        }
    case 2:
        if(Destination=="lahore"){
            Price=6000;
        }
        else if(Destination=="karachi"){
            Price=5000;
        }
        else{
            Price=4500;
        }
    case 3:
        if(Destination=="lahore"){
            Price=4000;
        }
        else if(Destination=="karachi"){
            Price=3000;
        }
        else{
            Price=2500;
        }
    }
            Tax = CalculateTax(choice,Price); // Get Tax info
            Fare = CalculatePrice(Price, Tax); // Calling Calc. Price function which prints the data and also returns Total Fare so we can use for writing.
            WriteData(Name, Address, Date, Destination, Flight, Seat, Fare); // Writing down record
        }
    }

};
int airFare::CalculateTax(int choice, int Price){
    switch(choice){
    case 1:
        Tax=30*Price/100;
        break;
    case 2:
        Tax=20*Price/100;
        break;
    case 3:
        Tax=10*Price/100;
        break;
    }
    return Tax;
};
void airFare::WriteData(string Name, string Address, string Date, string Destination, int Flight, int Seat, int Fare)
{
    ofstream record("Fare.txt", ios::out | ios::binary);
    if(!record)
    {
        cout "Cannot write to file.\n"; // raise exception, can use catch & throw if was asked in assignment
        return;
    }
    else //lets finish this and write every thing to Fare.txt
    {
        record "Name: " Name endl;
        record "Address: " Address endl;
        record "Date: " Date endl;
        record "Destination: " Destination endl;
        record "Flight No: " Flight endl;
        record "Seat No: " Seat endl;
        record "Fare: " Fare endl;
        record.close();
        cout "\n\nYour reservation has been successfully completed.\n\n";
    }
};
int airFare::CalculatePrice(int Price, int Tax){
    int adPrice = Tax + Price;
    ALine = 15*adPrice/100;
    Fare = ALine + Tax + Price;
    cout "\nBasic Price: "Price"\n";
    cout "Tax: "Tax"\n";
    cout "Air Line Charges: "ALine" ( 15% of Price + Tax)\n";
    cout "Total Fare: "Fare"\n";
    return Fare;
};
 main ()
     {
          airFare Fare; // Creating object of class airFare
          Fare.GetData(); // Firing Chain of events
          Fare.~airFare(); // Destroying object of class airFare
          cout "Press any key to exit"; // Waiting for the user to note down details.
          system("pause>null"); //Preventing typical "Press any key to continue" message
     }

koi tu share kar dy, kal last date hai.

solution mily ga??????????????????

cs201 assignment solution

Attachments:

Program run karo to Unable to open file q ata hai??? Umeed plz tell me. . . 

 

sonia sis mera to programm run  ho raha hai

run ho raha hai, par working tu nahi kar raha na

CS201 assignment 5 solution file

Attachments:

RSS

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

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

.