Answer to Question #264748 in C++ for Talha

Question #264748

Q4: Create a Car class. Identify the attributes and functions of the class (with respect to driver and not engineer)


For Example:


Attribute: No. of Seats


Function: accelerate() or startCar()

1
Expert's answer
2021-11-11T17:30:03-0500
#include <iostream>


using namespace std;
class Car{
public:
    int seats;
    char model[20];
    void getDetails(){
    cout<<"Enter car model: \n";
    cin>>model;
    cout<<"Enter number of seats: \n";
    cin>>seats;


    }
    void dispalyDetails(){
    cout<<"\nmodel\tseats";
    cout<<"\n"<<model<<"\t"<<seats<<endl;
    }
    void startcar(){
    cout<<"Car is on\n"<<endl;
    }
    void accelerate(){
    cout<<"the car is accelerating\n"<<endl;
    }



};


int main()
{
   Car c;
   c.getDetails();
   c.dispalyDetails();
   c.startcar();
   c.accelerate();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS