#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;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Here is my code: 

#include<stdio.h>
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...\n");
for (i = 0;i < 3;i++) {
tours[i] = getData();
}
min = tours[0].city;
for (i = 0;i < 3;i++) {
if (tours[i].distance < min)
min = tours[i].distance;
}
printf("\n");
for (i = 0;i < 3; i++) {
if (tours[i].distance == min) {
printTour(&tours[i]);
}
}
getchar();
return 0;
}
void printTour(tourType* x) {
printf("Shortest Tour\n---------------\n");
printf("City name: %s\n", (*x).city);
printf("Distance: %d\n", (*x).distance);
printf("Travel time: %02d:%02d:%02d", (*x).time.hr, (*x).time.min, (*x).time.sec);
}
tourType getData() {
tourType x;
char a[5], b[5], c[5]; //Will be used for time input
printf("Enter a city name: ");
scanf("%s", &x.city);
printf("Enter an integer distance: ");
scanf("%d", &x.distance);
printf("Enter travel time as HH:MM:SS ");
scanf("%[^:]:%[^:]:%[^\n]", a, b, c);

return x;

 

but i need it to what is in the picture in C programming

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 timeType, With a struct named timeType_struct
• contain 3 data members:
o hours, minutes, and seconds as integer values
Your second new typef should:
• be named tourType, with a struct named tourType_struct
• contain 3 data members:
o a 50 character city name
o an integer distance
a travel time as data type timeType
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
Transcribed Image Text: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 timeType, With a struct named timeType_struct • contain 3 data members: o hours, minutes, and seconds as integer values Your second new typef should: • be named tourType, with a struct named tourType_struct • contain 3 data members: o a 50 character city name o an integer distance a travel time as data type timeType 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education