Answer to Question #271525 in C++ for sam

Question #271525

define a class called vehicle that will store two items of information about a vehicle: the fuel capacity and the fuel consumption in kilometers per litre and prototype of four functions a default constructor and a parameterized constructor that initializes the taxi fuel capacity to 20 litres and taxi consumption to 10 kpl , a destructor and a friend function that uses the values from the constructors to calculates the taxi range (the maximum distance it would travel if its fuel tank is full without refueling) nb. show only the prototype of the function in the class


1
Expert's answer
2021-11-26T07:07:59-0500
#include <iostream>




using namespace std;




class vehicle{
  private:
    int fuelCapacity;
    int fuelConsumption;
    
  public:
    vehicle(){
        
    }
    vehicle(int cap,int con){
        fuelCapacity=20;
        fuelConsumption=10;
    }
    void setFuelCapacity(int cap);
    void setFuelConsumption(int con);
    int getFuelCapacity();
    int getFuelConsumption();
    friend void calculate();
    ~vehicle(){
        
    }
};
void vehicle :: setFuelCapacity(int cap){
    fuelCapacity=cap;
}
void vehicle :: setFuelConsumption(int con){
    fuelConsumption=con;
}
int vehicle::getFuelCapacity(){
    return fuelCapacity;
}
int vehicle::getFuelConsumption(){
    return fuelConsumption;
}
int main()
{
    vehicle v;




    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