Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my code: #include struct timeType_struct { int hr; int min; int sec; }; typedef struct timeType_struct timeType; struct tourType { char city[50]; int

Here is my code:

#include struct timeType_struct { int hr; int min; int sec; }; typedef struct timeType_struct timeType; struct tourType { char city[50]; int distance; timeType time; }; typedef struct tourType tourType; void printTour(tourType *); tourType getData(); tourType tours[3]; int main() { int i=0, min; printf("Enter tour data for 3 cities... "); for (i = 0;i

return x; }

I get these errors whenever I try to run it (see screenshot)

image text in transcribed

I need it to output like the picture I attached. C programming!

image text in transcribed

user@mimir: /cpsc1010_s21/chapterproject_71 > gcc -Wall c7.1.c c7.1.c: In function 'main': c7.1.c:39:5: warning: assignment to 'int' from 'char *' makes integer fro m pointer without a cast [-Wint-conversion] min = tours[0].city; c7.1.c: In function 'getData': c7.1.c:63:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*) [50]' [-Wformat=] scanf("%s", &x.city); user@mimir: ~/cpsc1010_s21/chapterproject_71 > DESCRIPTION Write a program that prompts a user to input the city name, distance, and travel time for three destination citites. Your program will use 2 new typedef structs to store the information, then find and output the tour with the shortest distance. Your first new typedef should: be named time Type, with a struct named time Type_struct contain 3 data members: o hours, minutes, and seconds as integer values Your second new typer should: be named tourType, with a struct named tourType_struct contain 3 data members: o a 50 character city name o an integer distance o a travel time as data type time Type Your program will need the following 2 functions: a function that prompts a user to input the values for the data members of a tourType struct and returns the tourType struct to the calling function a void function that takes a tourType parameter and prints the data in the struct Within your main function you will need to: Create a 3 element tourType array use your value-returning function to prompt for and read data into the array loop through the array to find the tour with the shortest distance use your void function to print the tour with the shortest distance NOTES: Be sure to include your function prototypes before your main function, and your function definitions after your main function. Sample output (sample input shown with underline): Enter tour data for 3 cities: Enter a city name: Chicago Enter an integer distance: 300 Enter travel time as HH:MM:SS: 06:00:01 Enter a city name: Pittsburgh Enter an integer distance: 600 Enter travel time as HH:MM:SS: 10:30:00 Enter a city name : Miami Enter an integer distance: 500 Enter travel time as HH:MM:SS: 08:00:00 Shortest Tour City name: Chicago Distance: 300 Travel time: 06:00:01

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

Step: 3

blur-text-image

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions