Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HI! I need 3 separate programs on C++. Every next one should contain parts from

ID: 3605989 • Letter: H

Question

HI! I need 3 separate programs on C++. Every next one should contain parts from previous one. Requirments are provided below. Thank you!

Problem C1

Order of functions in the code:

Within the Car class:

setup

output

Global functions, outside of the Car class:

main

input

Define a class named: Car
containing the following private data:

Note:
A destination is required if the car is loaded.
If it is not loaded the destination may be either a destination or the word "NONE".
Be sure to allow the user the option of entering a destination when the car is not loaded.

Within the class create the following member functions:

setup

Is a member function of the class Car

Takes the five parameters by value: reportingMark, carNumber, kind, loaded, and destination

Puts the data in the object

Has a return type of void

output

Is a member function of the class Car

Has no parameters

Prints the member data in a neat format

Has a return type of void

After the class, create the following global functions:

main

Contains six variables:

a pointer named ptr which points to a Car object

a string named reportingMark to contain two to four characters

an int named carNumber

a string named kind which could contain: "business" "maintenance" or "other"

a bool named loaded

a string named destination containing a destination or the word NONE

Uses new to obtain space for an object of type Car

Calls the input, setup, and output functions

Deletes the space obtained using new

input

Is a global function, not a member of the class

Takes the reportingMark, carNumber, kind, loaded, and destination as reference parameters

Reads the reportingMark, carNumber, kind, loaded, and destination from the user

Has a return type of void

Test your program with the following data:

Problem C2

Copy the solution from problem C1.

Order of functions in the code:
Note that the setup and output functions have been moved to a different location.

Car constructors and destructor within the Car class definition

default constructor

copy constructor

other constructors

destructor

main

Car member functions declared within the Car class but defined later

setup

output

input

Make the following additions and changes:

Build three constructors and a destructor for your Car class:A default constructor. Build this constructor with only one line of code that calls the setup member function. Set the following values:

A copy constructor. Build this constructor with only one line of code that calls the setup member function.

A constructor that accepts five parameters. Build this constructor with only one line of code that calls the setup member function.

A destructor that does nothing.

Put a declaration in the Car class for the setup and output functions. (The declaration is just the prototype)
Put the definition of these functions later. (The definition of a function contains the code)

Remove the call to the setup function from the main function.

Remove new and delete from the main function.

Revise the main function to create three Car objects in the stack by using the three constructors:

car1 which uses the values read from the user. Use the same values used to test assignment C1.

car2 which is copied from car1.

car3 which is created with the default constructor.

Then add code in the main function to print these headings and use the output member function to print the data for each of the three cars:

Problem C3

Copy the solution from problem C2.

Order of functions in the code:
Note that the order is not changed, but with the operator== function added.

Car constructors and destructor within the Car class definition

default constructor

copy constructor

other constructors

destructor

main

Car member functions declared within the Car class but defined later

setup

output

operator== with Car parameters

input

Create a friend function for the function operator== which tests to see if two objects are equivalent. The two objects are equivalent if they have the same reportingMark and carNumber (do not look at the kind, loaded, and destination fields).

Add the following code in main:

Test with the same data as in problem C2.

reportingMark a string with the AAR reporting mark carNumber an int kind a string which could contain "business" "maintenance" or "other" loaded a bool destination a string with a destination or the word "NONE"

Explanation / Answer

class car{

string reportingMark;
int carNumber;
string kind={"business","maintenance "," other"};
bool loaded;
string destination;
}

class c1

{

string reportingMark=SP;
int carNumber=34567;
string kind="business";
bool loaded=true;
string destination=Salt Lake City;
}

class c2

{

string reportingMark=NULL;
int carNumber=0;
string kind="other";
bool loaded=false;
string destination=NONE;
}

class c3{

string reportingMark=NULL;
int carNumber=0;
string kind="other";
bool loaded=false;
string destination=NONE;

car()
{

if(c1==c2)
cout<<"c1 is same as the c2 ";
else
cout<<"c1 is not same as the c2 ";

if(c2==c3)

cout<<"c2 is same as the c3 ";

else

cout<<"c2 is not same as the c3";

}

friend void car(c3)

};