Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


Correct and Final Solution of Assignment No.3 Of CS201 Due Date 14 Jan 2013 Solved by Waqas Rasheed

Views: 4263

Replies to This Discussion

bro will u please upload .cpp file?

No. ap khud lilkhoo. theek likhoo compile na hoto mai zimmadaar hon

jo loog solution ko ghalaat bata rahe hien .. after deadline mai ccp file b de do ga.. phr chck kar lena.. solution theek tha ya nahi..ya ap sirf ap ke mistake the

yar end kese krna hai

yeh lo aur mooj maro 

Attachments:

This is wrong solution...

Correct solution is this

check it geys.. just run it on devc++

Attachments:

Rao Usman

its a wrong solution becasuse of you did not dynamaclly allocate the memory..

my solution is 100% correct

using namespace std;

#include<iostream>

#include<conio.h>

class Vehicle{
      private:string company;
              string model;
              double year;
              double engineCapacity;
              public:
              void setCompany(string cmp)
              {company = cmp;
                   }
              string getCompany()
              {
                     return company;
                     }
              void setModel(string md)
              {
                   model = md;
                   }
              string getModel()
              {
                     return model;
                     }
              void setYear(double yr)
              {
                   year = yr;
               }
               double getYear()
               {
                return year;      
                      }
                void setEngineCap(double eCap)
                {
                     engineCapacity = eCap;
                     }
                double getEngineCap()
                {
                       return engineCapacity;
                 }

Vehicle *ptr;
      int numVehicle;
      void getInput()
      {cout"Enter number of vehicle:";
           cin>>numVehicle;
           ptr = new Vehicle[numVehicle];
           for(int i=0;i<numVehicle;i++)
           {string Cmp;
                   cout"\n\nVehicle "i+1endl;
                   cout"Enter the name of Vehicle maker company :";
                   cin>>Cmp;
                   ptr[i].setCompany(Cmp);
                   string md;
                   cout"Enter Vehicle model :";
                   cin>>md;
                   ptr[i].setModel(md);
                   double rg;
                   cout"Enter year of registration:";
                   cin>>rg;
                   ptr[i].setYear(rg);
                   double egC;
                   cout"Enter engine of thr Vehicle:";
                   cin>>egC;
                   ptr[i].setEngineCap(egC);
                   }

}
void display()
{ for(int i=0;i<numVehicle;i++)
     {
      cout"\n\n\nVehicle"i+1endl;
      cout"\nCompany :"ptr[i].getCompany()endl;
      cout"\nModel: "ptr[i].getModel()endl;
      cout"\nYear:"ptr[i].getYear()endl;
      cout"\nEngine Capacity in CC:"ptr[i].getEngineCap()endl;
      }
      }

Vehicle()
      {
               company = "ABC";
               model = "xyz";
               year = 2009;
               engineCapacity = 1000;
               }
      ~Vehicle()
      { cout"\nObject deleted\n";
                 }
                 };
                 int main()
                 {
                     Vehicle obj;
                     obj.getInput();
                     obj.display();
                     delete[] obj.ptr;
                     getch();
                     }                 
                        //by Emran Haakim

RSS

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

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