Make your own free website on Tripod.com
« September 2018 »
S M T W T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
You are not logged in. Log in
Entries by Topic
All topics  «
Blog Tools
Edit your Blog
Build a Blog
RSS Feed
View Profile
Final
Tuesday, 13 May 2008
Final

#include <iostream>
using namespace std;

void Clear_Screen(void);

class Transport
{
protected:
   int people;
   float weight, maxSpeed;
public:
   Transport(int, float, float);
   ~Transport(){ return;}
   virtual void setPeople();
   virtual void setWeight();
   virtual void setMaxSpeed();
   virtual int getPeople(){ return people;}
   virtual float getWeight(){ return weight;}
   virtual float getMaxSpeed(){ return maxSpeed;}
   virtual void input(){ setPeople(), setWeight(), setMaxSpeed();}
   virtual void inputTransport()=0;
   virtual void output();
   virtual void outputTaxes()=0;
};

Transport::Transport(int MaxPeople, float MaxWeight, float MaxSpeed): people(MaxPeople), weight(MaxWeight),
maxSpeed(MaxSpeed)
{
   return;
}

void Transport::setPeople()
{
   cout << "\nPlease enter number of people in your transport:\n";
   cin >> people;
   return;
}

void Transport::setWeight()
{
   cout << "\nPlease enter the weight in pounds of your transport:\n";
   cin >> weight;
   return;
}

void Transport::setMaxSpeed()
{
   cout <<"\nPlease enter the max speed in miles per hour of your transport:\n";
   cin >> maxSpeed;
   return;
}

void Transport::output()
{
   Clear_Screen();
   cout << "\nPeople in transport: " << getPeople();
   cout << "\nWeight of transport: " << getWeight() << " pounds";
   cout << "\nMax Speed: " << getMaxSpeed() << " Miles/Hour";
   return;
}

class Vehicle : virtual public Transport
{
protected:
   int axles;
   float taxes;
public:
   Vehicle(int, float, float, int, float);
   ~Vehicle(){ return;}
   virtual void setAxles();
   virtual void setTaxes();
   virtual int getAxles(){ return axles;}
   virtual float getTaxes(){ return taxes;}
   virtual void input(){ setAxles(), setTaxes();}
   virtual void inputTransport(){ Transport::input(), setAxles(), setTaxes();}
   virtual void output();
   virtual void outputTaxes();
};

Vehicle::Vehicle(int MaxPeople, float MaxWeight, float MaxSpeed, int MaxAxles, float MaxTaxes):
   Transport(MaxPeople, MaxWeight, MaxSpeed), axles(MaxAxles), taxes(MaxTaxes)
{
   return;
}

void Vehicle::setAxles()
{
   cout << "\nPlease enter the number of axles on your motor vehicle:\n";
   cin >> axles;
   return;
}

void Vehicle::setTaxes()
{
   taxes = (100 / axles) + (5*(people - 6)) + ((50*(weight-2000)) / 1000);
   return;
}

void Vehicle::output()
{
   cout << "\nAxles: " << getAxles();
   return;
}

void Vehicle::outputTaxes()
{
   Transport::output();
   output();
   cout << "\nTaxes for Motor Vehicle: $" << getTaxes();
   return;
}

class Vessel : virtual public Transport
{
protected:
   float foot, taxes;
public:
   Vessel(int, float, float, float, float);
   ~Vessel(){ return;}
   virtual void setFoot();
   virtual void setTaxes();
   virtual float getFoot(){return foot;}
   virtual float getTaxes(){ return taxes;}
   virtual void input(){ setFoot(), setTaxes();}
   virtual void inputTransport(){ Transport::input(), setFoot(), setTaxes();}
   virtual void output();
   virtual void outputTaxes();
};

Vessel::Vessel(int MaxPeople, float MaxWeight, float MaxSpeed, float MaxFoot, float MaxTaxes):
   Transport(MaxPeople, MaxWeight, MaxSpeed), foot(MaxFoot), taxes(MaxTaxes)
{
   return;
}

void Vessel::setFoot()
{
   cout<<"\nPlease enter the length of the vessel in feet:\n";
   cin >> foot;
   return;
}

void Vessel::setTaxes()
{
   taxes = 10 * foot;
   return;
}

void Vessel::output()
{
   cout << "\nLength of vessel: " << getFoot() << " ft";
   return;
}

void Vessel::outputTaxes()
{
   Transport::output();
   output();
   cout << "\nTaxes for vessel: $" << getTaxes();
   return;
}

class Amphibious : public Vehicle, public Vessel
{
protected:
   float taxes;
public:
   Amphibious(int, float, float, int, float, float, float);
   ~Amphibious(){ return;}
   virtual void setTaxes(){ taxes = Vehicle::getTaxes() + Vessel::getTaxes();}
   virtual float getTaxes(){ return taxes;}
   virtual void input(){Vehicle::input(), Vessel::input(), setTaxes();}
   virtual void inputTransport(){Transport::input(), Vehicle::input(), Vessel::input(), setTaxes();}
   virtual void output(){ Transport::output(), Vehicle::output(), Vessel::output();}
   virtual void outputTaxes();
};

Amphibious::Amphibious(int MaxPeople, float MaxWeight, float MaxSpeed, int MaxAxles, float MaxTaxes1, float MaxFoot, float MaxTaxes2):
   Vehicle(MaxPeople, MaxWeight, MaxSpeed, MaxAxles, MaxTaxes1),
   Vessel(MaxPeople, MaxWeight, MaxSpeed, MaxFoot, MaxTaxes2),
   Transport(MaxPeople, MaxWeight, MaxSpeed)
{
   return;
}

void Amphibious::outputTaxes()
{
   output();
   cout << "\nTaxes for Amphibious: $" << getTaxes();
   return;
}


class Aircraft: virtual public Transport
{
protected:
 int passengers;
 float wingspan;
 float taxes;

public:
 Aircraft(int occupants, float length, float tax, int MaxPeople, float MaxWeight,
    float MaxSpeed):Transport(MaxPeople, MaxWeight, MaxSpeed)
 {
       passengers=occupants;
    wingspan=length;
    taxes=tax;
 }
    ~Aircraft(){}
    virtual void setPassengers()
 {
       cout<<"\nHow many passengers can ride on this aircraft? ";
    cin>>passengers;
    cout<<endl;
 }
 virtual void setWingSpan()
 {
       cout<<"\nWhat is the length from wing tip to wing tip?  ";
    cin>>wingspan;
    cout<<endl;
 }
 virtual void setTaxes()
 {
  taxes = (50.00 * passengers) + (40.00 * wingspan);
 }
 virtual int getPassengers()
 {
       return passengers;
 }
 virtual float getWingSpan()
 {
       return wingspan;
 }
 virtual float getTaxes()
 {
       return taxes;
 }
    virtual void input()
 {
   setPassengers();
   setWingSpan();
   setTaxes();
 }
    virtual void inputTransport()
 {
   setWingSpan();
   setPassengers();
   setTaxes();
 }
    virtual void output()
 {
    cout<<endl;
       cout<<"The lenght of the aircraft from wing tip to wing tip is "<<getWingSpan()<<endl;
 }
    virtual void outputTaxes()
 {
        Transport::output();
  output();
  cout<<"The tax for this aircraft is : $ "<<getTaxes()<<endl;
 }
};

int menu()
{
   int choice;
   cout << "\nWhat type of transport do you have:";
   cout << "\n1: Motor Vehicle";
   cout << "\n2: Vessel";
   cout << "\n3: Amphibious";
   cout << "\n4: Aircraft\n\n";
   cin >> choice;
   return choice;
}

int main()
{
   Transport *transport;
   int choice = 0;
   char again;
   cout << "\nThis program calculate the license taxes for your vehicle\n\n";
   do
   {
   choice = menu();
   Clear_Screen();
   switch(choice)
      {
         case 1:
            transport = new Vehicle( 0, 0, 0, 0, 0);
            transport->inputTransport();
            transport->outputTaxes();
            break;
         case 2:
            transport = new Vessel( 0, 0, 0, 0, 0);
            transport->inputTransport();
            transport->outputTaxes();
            break;
         case 3:
            transport = new Amphibious( 0, 0, 0, 0, 0, 0, 0);
            transport->inputTransport();
            transport->outputTaxes();
            break;
   case 4:
    transport = new Aircraft(0, 0, 0, 0, 0, 0);
    transport->inputTransport();
    transport->outputTaxes();
    break;
         default:
            cout << "\nInvalid entry. Please re-try.";
            break;
      }
      cout << "\n\n   Would you like to test again? (Y/N): ";
      cin >> again;
      Clear_Screen();
      }
      while (again =='y' || again =='Y');
      cout << "\nThank you for using the program!\n\nHit any key to exit\n";
      getchar(); getchar();
      return 0;
}

void Clear_Screen(void)
{
   #ifdef _WIN32
      system("cls");
   #else
      system("clear");
   #endif
}


Posted by veronicak5678 at 7:16 PM EDT

Newer | Latest | Older