Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, can I get assistence for this assignment? C++ Instructions: Define a class named Vehicle Public member prototypes: A void function named print with no

Hello, can I get assistence for this assignment?

C++ Instructions: Define a class named Vehicle Public member prototypes:

A void function named print with no parameters

A constructor with 2 integer parameters, each with a default value of 0 (zero)

Private members:

An integer to store the number of wheels.

An integer to store the number of doors.

After the Vehicle class definition:

Define the print function to display the number of wheels and doors see sample output.

Define the constructor to populate the private variables with the values of the parameters.

Define a class named Car that derives from the Vehicle class (as public) Public member prototypes:

A void function named print with no parameters

A constructor with 4 parameters: 3 integers each with a default value of 0 (zero), and 1 string with a default value of (empty string)

Private members:

An integer to store MPG (miles per gallon)

A string to store the model name

After the Car class definition:

Define the print function to display the model name and mpg, then call the parent (Vehicle) print function see sample output

Define the constructor to call the parent (Vehicle) constructor, then populate the private Car variables with the values of the parameters.

Define a class named Truck that derives from the Vehicle class (as public) Public member prototypes:

A void function named print with no parameters

A constructor with 5 parameters: 4 integers each with a default value of 0 (zero), and a string with a default value of (empty string)

Private members:

An integer to store MPG (miles per gallon)

An integer to store the number of tons the truck can carry

A string to store the model name

After the Truck class definition:

Define the print function to display the model name, mpg and tons, then call the parent (Vehicle) print function see sample output

Define the constructor to call the parent (Vehicle) constructor, then populate the private Truck variables with the values of the parameters.

In the main function Declare whatever local variables you need.

Prompt the user for details for a car (see sample output) and then declare a Car object.

Prompt the user for details for a truck (see sample output) and then declare a Truck object.

Call the print function for your car and your truck.

SAMPLE OUTPUT: Enter car details Number of wheels: 4 Number of doors: 4 MPG: 36 Model name: Toyota

Enter truck details Number of wheels: 18 Number of doors: 2 MPG: 22 How many tons can the truck carry: 5 Model name: Peterbilt

Toyota gets 36 miles per gallon and has 4 wheels and 4 doors. Peterbilt gets 22 miles per gallon, can cary 5 tons, and has 18 wheels and 2 doors.

Goodbye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions