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

#12 pg 597 of Malik C++ Programming 5th ed. Please use the following definitions

ID: 3627858 • Letter: #

Question

#12 pg 597 of Malik C++ Programming 5th ed.

Please use the following definitions for every question below to answer. Write the statements containing these definitions.

Suppose that you have the following definitions:

struct timeType                          struct tourType

{                                                {

int hr;                                        string cityName;

double min;                                 int distance;

int sec;                                       timeType travelTime;

};                                                };

a. Declare the variable destination of type tourType.

b. Write C++ statements to store the following data in destination:

     cityName-Chicago, distance- 550 miles, travelTime-9 hours

     and 30 minutes.

c. Write the definition of a function to output the data stored in a variable of type tourType.

d. Write the definition of a value-returning function that inputs data into a variable of type tourType.

e. Write the definition of void function with a reference parameter of type tourType to input data in a variable of type tourType.

Explanation / Answer

Declaring tourType variable

tourType destination;

b)

Assignment statements

destination.cityName = "Chicago";

destination.distance = 550;

destination.travelTime.hr = 9;

destination.travelTime.min = 30;

c)

Function definition to input values using reference parameter

void showTourTypeDate(tourType& tType)

{

    cout << tType.cityName;

    cout << tType.distance;

    cout << tType.travelTime.hr;

    cout << tType.travelTime.min;

    cout << tType.travelTime.sec;

}

d)

Function definition to input values using return type

tourType setTourType()

{

}

e)

void copyTourType(tourType& tType1)

{

    tourType tType2;

   

    tType2 << tType1.cityName;

    tType2 << tType1.distance;

    tType2 << tType1.travelTime.hr;

    tType2 << tType1.travelTime.min;

    tType2 << tType1.travelTime.sec;

}