this is simulated data on daily vehicle traffic crossing a bridge for one
week. From Monday through Sunday the daily vehicle counts were {986, 818, 638, 763,
992, 534, 683}. Create an input file named cars_data.dat containing these numbers.
Write a program that will read these values from the input file, and store the values in an
array. The single-dimension array of integers is to be a global variable. The program
should calculate the average daily traffic load of the bridge, and present information on
minimum and maximum traffic. Output should be to the screen in a format similar to the
following:
Day Vehicles
Monday 986
Tuesday 818
...
Sunday ...
Total Vehicles for the week:
Average daily vehicle count:
Day(s) with heaviest traffic count:
Day(s) with lightest traffic count:
Screen output should also be written to a file on the disk. Your program must use a
function solely for reading the data file into the memory array, a different function for
calculating the average, and yet a third function for output. Your program should be able
to accept input files with any values, and must be able to handle unusual situations (e.g.,
what if two days have the same number of cars?)
mikky05v
0
Newbie Poster
Recommended Answers
Jump to Postsince the array is global it isn't necessary to pass it as a parameter.
line 16: just make that a function call
reading_data_into_array();
line 21: make that a void function because it isn't necessary to return anything and delete the parameter because the array is global..line …
Jump to Postcreate two variables called heavest and lightest. Then create a loop like you did on line 33, but instead of adding up everything keep track of the heavest and lightest values. For example:
if( a[i] > heavest) heavest = a[i];
and do the same for lightest except …
All 8 Replies
mikky05v
0
Newbie Poster
mikky05v
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mikky05v
0
Newbie Poster
mikky05v
0
Newbie Poster
mikky05v
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
hammerhead
19
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.