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

Suppose that you have the following definitions: struct timeType { int hr; doubl

ID: 3717286 • Letter: S

Question

Suppose that you have the following definitions: struct timeType { int hr; double min; int sec; }; struct tourType { string cityName; int distance; timeType travelTime; }; Declare the variable destination of type tourType. Write C++ statements to store the following data in destination: cityName—Chicago, distance—550 miles, travelTime—9 hours and 30 minutes. Write the definition of a function to output the data stored in a variable of type tourType. Write the definition of a value-returning function that inputs data into a variable of type tourType. Write the definition of a void function with a reference parameter of type tourType to input data in a variable of type tourType.

C++

Explanation / Answer

Hi,

please rate.

Code:

#include<iostream>
#include<string>

using namespace std;

struct timeType
{
    int hr;
    double min;
    int sec;
};

struct tourType
{
    string cityName;
    int distance;
    timeType travelTime;
};
tourType destination;

tourType input(){
    cout<<"Enter the city, distance and time in hr and min"<<endl;
    cin>>destination.cityName;
    cin>>destination.distance;
    cin>>destination.travelTime.hr;
    cin>>destination.travelTime.min;

    return destination;
}

void display(){
    cout<<"City is "<<destination.cityName<<endl;
    cout<<"Distance is "<<destination.distance<<endl;
    cout<<"Time in Hour "<<destination.travelTime.hr<<endl;
    cout<<"Time in minutes "<<destination.travelTime.min<<endl;
}

void inputfunc(tourType *t){
    tourType d;
    d.cityName = t->cityName;
    d.distance = t->distance;
    d.travelTime.hr = t->travelTime.hr;
    d.travelTime.min = t->travelTime.min;
}

int main(){
    input();
    inputfunc(&destination);
    display();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote