Program Assignment #3, C/C++ Programming

Assignment Help:
Programming Assignment #3: Vehicle Track Performance Tests
Purpose: The purpose of this programming assignment is to give the student experience in using functions, arrays, and strings. Arrays will be used to store and process data and the graphing capabilities of Excel will be used to graph results calculated by the C++ program.
Reference: The PowerPoint presentation on data files on the instructor’s website includes an example of graphing the output of a C++ program using Excel.
Data file description:
Four data files (CAR1.DAT, CAR2.DAT, CAR3.DAT, and CAR4.DAT) are available on the instructor’s web page. Each file contains track results for a test vehicle. The results are in the following format:
• The test vehicle number (line 1).
• The test date (line 2).
• The test driver (line 3).
• Time, t, in seconds and distance, x, in feet (one pair of (t,x) values per line for all other lines)
As an example, the contents of CAR1.DAT are shown below:
Test vehicle: Car #1
Test date: October 26, 2007
Driver: D. Myers
0.0 0.0
0.2 5.5
0.4 15.9
0.6 30.9
0.8 49.7
1.0 71.8
1.2 97.1
1.4 125.4
1.6 156.6
1.8 190.4
2.0 226.6
2.2 265.3
2.4 306.1
2.6 348.9
2.8 393.5
3.0 439.9
3.2 488.0
3.4 537.7
3.6 588.8
3.8 641.2
4.0 694.6
4.2 749.2
4.4 804.7
4.6 861.2
4.8 918.4
5.0 976.2
Page 2
Determining velocity and acceleration using distance and time values:
Velocity, v, and acceleration, a, can be determined using values of distance, x, and time, t, as follows. By definition: v = dxdt and a = dvdt
These equations can be approximated by: v = change in distancechange in time and a = change in velocitychange in time
For the distance and time values in the data files provided, let’s assume that v = 0 and a = 0 at the first time value (0.0). We could then calculate velocity (in ft/s) and acceleration (in ft/s/s) at the second time value using: v1 = x1 - x0t1 - t0 and a1 = v1 - v0t1 - t0
Similarly at the third time value: v2 = x2 - x1t2 - t1 and a2 = v2 - v1t2 - t1
For the data file CAR1.DAT, this would yield: v1 = 5.5 - 0.00.2 - 0.0 = 5.5 ft0.2 s = 27.5 ft/s a1 = 27.5 - 0.00.2 - 0.0 = 27.5 ft/s0.2 s = 137.5 ft/s2
Similarly: v2 = 15.9 - 5.50.4 - 0.2 = 10.4 ft0.2 s = 52.0 ft/s 2ft/s 122.5 = s 0.2ft/s 24.5 = 0.2 - 0.427.5 - 52.0 = a2
The remaining values could be determined in a similar manner. It might also be more practical to express v in mph that in ft/s. A simple conversion factor can be used to convert v in ft/s to mph.
A table could now be created which includes t, x, v (in ft/s),
v (in mph) and a. This table for CAR1.DAT might look like:
t (s)
x (ft)
v (ft/s)
v (mph)
a (ft/s²)
0.0
0.0
0.0
0.0
0.0
0.2
5.5
27.5
18.8
137.5
0.4
15.9
52.0
35.5
122.5
0.6
30.9
75.0
51.5
115.0
5.0
976.2
289.0
197.0
15.0
Page 3
Program Requirements:
Write a C++ program that will accomplish the following:
1. The program should ask the user which data file is to be used (give an example name and path), read the file name as a string, and open the file using a string variable.
2. The program should read the vehicle number, date, and driver as strings. Also read the values of t and x from the file and store them in arrays. Assume that the data files will contain a maximum of 30 (t, x) data points.
3. Define arrays for velocity (in ft/s), velocity (in mph), and acceleration (in ft/s²). Use a separate function to calculate each of these arrays. For example, the function to find velocity in f/s might be called using Velocity (t,x,v,size) where t and x are input arrays, v is an output array, and size is the number of data points in each array.
4. Write a general function that can be used to find the average of any array. Call this function twice in order to find average velocity (in mph) and average acceleration (in ft/s² or ft/s/s). For example, the function might be called as follows:
Average = ArrayMean(A, Asize); //function call to find mean value in array A
5. Write a general function that can be used to find the maximum of any array. Call this function twice in order to find maximum velocity (in mph) and maximum acceleration (in ft/s² or ft/s/s). For example, the function might be called as follows:
Max = ArrayMax(A, Asize); //function call to find max value in array A
6. The output of the program should be sent to a data file (the name of the data file should be specified by the user, but give an example name and path). The output should include:
• The test vehicle number
• The test date
• The driver
• The average velocity in mph
• The average acceleration in ft/s/s
• The maximum velocity in mph
• The maximum acceleration in ft/s/s
• Values for time, distance, velocity (ft/s), velocity (mph), and acceleration (ft/s/s) for each of the data points in the input data files (i.e., 5 numbers per line).
The file should include commas between each numeric value so that the file can be imported into Excel as a “Commas Delimited File”. The output data file for CAR1.DAT might look as follows:
As an example, the output file generated for the input CAR1.DAT is shown below:
Test vehicle: Car #1
Test date: October 26, 2007
Driver: D. Myers
Average velocity = aaa mph
Average acceleration = bbb ft/s/s
Maximum velocity = ccc mph
Maximum acceleration = ddd ft/s/s
0.0,0.0,0.0,0.0,0.0
0.2,5.5,27.5,18.8,137.5
0.4,15.9,52.0,35.5,122.5
0.6,30.9,75.0,51.5,115.0
·
·
·
5.0,976.2,289.0,197.0,15.0
Page 4
7. Run your program for any two of the data files.
• Import each of the output data files into Excel.
• Add titles to each column, lines, numeric formatting, etc., to enhance the appearance and readability of the data.
• Form four graphs: x vs t, v vs t (in ft/s), v vs t (in mph), and a vs t.
• In addition to standard report requirements, be sure to include a printout of your program, a printout of all 4 input data files, a printout of all 4 output data file, and the spreadsheet table and graphs for the two files that you selected.
Extra Credit Suggestions: (for a maximum of 10 additional points on the program grade)
1. Use additional functions. For example, a function could be used to create an output data file.
2. Give the user the option of specifying standard or SI units (user selects A or B below):
A) distances in the data file are in feet: then calculate v (in ft/s), v (in mph), and a (in ft/s/s)
B) distances in the data file are in meters: then calculate v (in m/s), v (in km/h), and a (in m/s/s)
3. Instead of using five one-dimensional arrays for t, x, v (in ft/s), v (in mph), and a (in ft/s/s), use a single two-dimensional array (5 by 30).
4. Expand the idea above to use a three-dimensional array where the third dimension corresponds to the input data file number (1, 2, 3, or 4). Read all four data files when the program starts to fill the array. The program output should then be automatically sent to the four output data files. No user input would be required in running the program.
5. Use your imagination!

Related Discussions:- Program Assignment #3

Araay, create two array names and grade .in first array you have to store t...

create two array names and grade .in first array you have to store thease 10 names 1.a,2.3.r,4.s,5.l,6.k,7.n,8.b,9.z,10.d you have to enter grades for thease students.te program mu

Explain string constants in c language - escape sequences, Explain string c...

Explain string constants in c language - Escape Sequences? Illustrations are "945", "hello", "well done", "5+3". The character constant (example 'x') isn't equivalent to the st

Miniumshelf, write a prgm to find minimum total number of shelves including...

write a prgm to find minimum total number of shelves including the intial one required for loading process

Compiling/ installing openvpn client within an ip camera, Project Descripti...

Project Description: I want someone with experience on adding/compiling/installing the OpenVPN client software within an IP network camera's embedded operating system. Either if

Identifier and constant, What are  Id e n t i f ie rs a n d C o...

What are  Id e n t i f ie rs a n d C o n s t a n ts in C++? Id e n t i f ie r a n d C o n s t a n t : I d e n t i f ie r

C program for function of merge , C Program for FUNCTION OF MERGE #inc...

C Program for FUNCTION OF MERGE #include conio.h> #include stdio.h> char cot(char a[],char b[]); void main() {           char a[50],b[50];           clrscr()

#title.need help finising a pseudo code, I have to make a program that allo...

I have to make a program that allow the user input 10 numbers between 10 and 100 and if the number input is the same than the last number, should appear an error message. I have th

Search property from catalogue , Implement the search property from catalo...

Implement the search property from catalogue menu option.  After selecting this option the user should be asked to specify the property using the following sub-menu: 1. Specif

Pointer, void main() { int *p, *q, i ; p=(int*)100; q=(int*)200; i=q-p; pr...

void main() { int *p, *q, i ; p=(int*)100; q=(int*)200; i=q-p; printf("%d",i); } }

C , why c is middle level language?

why c is middle level language?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd