c++ programming language Suppose that you have die following definitions: (8) st
ID: 3819651 • Letter: C
Question
c++ programming language
Suppose that you have die following definitions: (8) struct timeType {int hr; double min; double min; int sec;}; struct tourType {string cityName; int distance; timeType travelTime;}; a. Declare the Virile destination of type tourType. b. Write C++ statements to store die 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 die definition of a value-returning function that inputs data into a variable of type tourType. e. Write die definition of a void function with a reference parameter of type tourType to input data in a variable of type tourType.Explanation / Answer
a)
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()
{
tourType tType;
cin << tType.cityName;
cin << tType.distance;
cin << tType.travelTime.hr;
cin << tType.travelTime.min;
cin << tType.travelTime.sec;
return tType;
}
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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.