Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the given struct below, create the two following functions do not modity the function declarations-o points if you do this): void till_train train_car train,

image text in transcribed
Using the given struct below, create the two following functions do not modity the function declarations-o points if you do this): void till_train train_car" train, FILE "p) (50 points) This function takes an array of train_carstructs and fills each struct with info from a file (sample file given below-do not HARDCODE THE FILE) (20 points. The size of the array is determined by the number of lines in the file (5 points for example, it a file has 3 fines of info, then that means the array is size 3 (hint the easiest way to do this is to read in the file a specific way). The price member in a struct should be 5.99 if the number of passengers is less than 10 (10 pointsland 10.99 otherwise (10 points. Don't forget to close the file when you are done 5 points). vold print_train(train_car trainint size) (30 points) This function prints out the info from the struts that make up the trainarray. For the sample file given the output would look like: Train car 1:25 passengers, price: $10.99 Train car 2:30 passengers, price: $10.99 Train car 3:4 passengers, price: $5.99 (10 points correctly accessing each array. 7.5 points correctly printing each passenger amount. 7.5-correctly printing each price, 5 points-overall correct match for each line in the sample run Struct: typedet struct train cart int num passengers: char size: float price: train_car: Sample File: 25-minumber of passenger size 30-1

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_2

Step: 3

blur-text-image_3

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions